wiki:DeveloperGuidelines/EdenMobile/Conventions

Version 1 (modified by Dominic König, 6 years ago) ( diff )

--

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:

Quotes

In alignment with Eden conventions, EdenMobile uses single quotes for string literals.

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:

EdenMobile.controller('EMSynchronisationController', [
    '$scope', '$state', '$stateParams',
    function($scope, $state, $stateParams) {

    }
]);

All other components use the lowercase prefix:

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:

function MyConstructor() {
    this.someAttribute = 'example';
}

Variables, attributes, methods use the lowercase camelCase:

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:

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
Note: See TracWiki for help on using the wiki.