Changes between Initial Version and Version 1 of DeveloperGuidelines/EdenMobile/Conventions


Ignore:
Timestamp:
10/12/16 06:58:02 (8 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/EdenMobile/Conventions

    v1 v1  
     1= EdenMobile Coding Conventions =
     2
     3We want to follow a consistent coding style and naming conventions in EdenMobile.
     4
     5Everything that is not described on this page, should aim to follow the AngularJS Style Guide:
     6
     7- https://github.com/mgechev/angularjs-style-guide
     8
     9== Quotes ==
     10
     11In alignment with Eden conventions, EdenMobile uses ''single quotes'' for string literals.
     12{{{#!js
     13var aString = 'use single quotes for string literals';
     14}}}
     15
     16== Naming Conventions ==
     17
     18For names of AngularJS components of EdenMobile, such as services, directives, controllers, etc we use the '''em''' prefix.
     19
     20Controllers use the uppercase prefix:
     21{{{#!js
     22EdenMobile.controller('EMSynchronisationController', [
     23    '$scope', '$state', '$stateParams',
     24    function($scope, $state, $stateParams) {
     25
     26    }
     27]);
     28}}}
     29
     30All other components use the lowercase prefix:
     31{{{#!js
     32EdenMobile.directive('emExampleDirective', [
     33    '$compile',
     34    function($compile) {
     35
     36    }
     37]);
     38}}}
     39
     40For all other !JavaScript, we use '''camelCase''' (or !PascalCase, respectively) - not underscores as word separator - without the em-Prefix.
     41
     42Classes (=constructor functions) use the uppercase !PascalCase:
     43{{{#!js
     44function MyConstructor() {
     45    this.someAttribute = 'example';
     46}
     47}}}
     48
     49Variables, attributes, methods use the lowercase camelCase:
     50{{{#!js
     51var doSomething = function(param) {
     52    var localVariable = param + 7;
     53}
     54}}}
     55
     56== Global Variables ==
     57
     58Ideally, there should be only very few global variables - wherever possible, they should be defined as AngularJS services instead:
     59
     60{{{#!js
     61EdenMobile.value('emGlobalVariable', 'some value');
     62}}}
     63
     64...or using the factory method, respectively.
     65
     66Exceptions:
     67
     68- the {{{EdenMobile}}} module (=the application itself)
     69- {{{CordovaApp}}}, which provides access to the Cordova layer