= EdenMobile Coding Conventions = We want to follow a consistent coding style and naming conventions in EdenMobile. Everything that is not described on this page, should aim to follow the AngularJS Style Guide: - https://github.com/mgechev/angularjs-style-guide == Quotes == In alignment with Eden conventions, EdenMobile uses ''single quotes'' for string literals. {{{#!js var aString = 'use single quotes for string literals'; }}} == Naming Conventions == For names of AngularJS components of EdenMobile, such as services, directives, controllers, etc we use the '''em''' prefix. Controllers use the uppercase prefix: {{{#!js EdenMobile.controller('EMSynchronisationController', [ '$scope', '$state', '$stateParams', function($scope, $state, $stateParams) { } ]); }}} All other components use the lowercase prefix: {{{#!js EdenMobile.directive('emExampleDirective', [ '$compile', function($compile) { } ]); }}} For all other !JavaScript, we use '''camelCase''' (or !PascalCase, respectively) - not underscores as word separator - without the em-Prefix. Classes (=constructor functions) use the uppercase !PascalCase: {{{#!js function MyConstructor() { this.someAttribute = 'example'; } }}} Variables, attributes, methods use the lowercase camelCase: {{{#!js var doSomething = function(param) { var localVariable = param + 7; } }}} == Global Variables == Ideally, there should be only very few global variables - wherever possible, they should be defined as AngularJS services instead: {{{#!js EdenMobile.value('emGlobalVariable', 'some value'); }}} ...or using the factory method, respectively. Exceptions: - the {{{EdenMobile}}} module (=the application itself) - {{{CordovaApp}}}, which provides access to the Cordova layer