2. What are Coding Standards
Coding standards are guidelines for code style
Why Have Coding Standards
Greater consistency between developers
Easier to develop and maintain
3. CODING STANDARDS
Home page developed first
Naming Convention
Code Alignment
Code Commenting
Validate HTML and CSS
6. CODE COMMENT
/** Function to get customer details
@functionName: customerDetails
@params:{customerId:’’}
**/
$scope.customerDetails=function(){
//Call customer service to get fetch customer
details
}
7. NAMING CONVENTION
Do not use number as variable like number1,span2
etc.
Write name of file, folder ,function related to code.
Use camelCase-For example- customerDetails
8. FOLDER STRUCTURE
All common file should be in common folder. Directives, filters in
common folder as directives.js,filter.js
CSS folder- inside module specific CSS, one master CSS file for
common.
All third party JS would be in vendor folder.
Pages Folder - Example- profile- ->profile.html,
profileController.js,profileServices.js (service file would be common
for subfolder) ,if profile has subfolder then -profile->personal-
>personal.html,personalController.js.
Image folder –module wise.
9. DON’T
Do not declare constant/global value in every files, Use a common
file.
Do not use localStorage.
Do not console.log();
Don’t used $apply();
Remove extra injection- like $rootScope if you are not using it do not
inject.
Do not write inline CSS.
10. Do not use var in angular project.
Do not use $stateParams, $rootScope, instead of these use
services, because $stateParams does not reset when transitioning
back to current state.
Local Storage- If we are working on offline facility then store
sensitive data in encoded form in SQLite.
11. DO
Proper comments for functions, services, controllers and variables
Remove console.log once you are done.
Use class for css.
Use keyword “use strict” in controllers, because it disallows global
variables.
Write common function if applicable.
Clean services after logout-(make common file).