- All code files should be named in kebab-case. That is all lowercase and words separated by hyphen (-)
e.g. base-entity.js, base-entity.json, config.json etc.
-
Model names should always be in PascalCase. That is created by concatenating capitalized words. e.g. BaseEntity, AppUser etc.
-
Model name should be singular noun.
e.g. AppUsers is not a correct model name. -
Model plural should be in camelCase. That is same as PascalCase, but 1st character of 1st word is in lower case.
-
Model property names should be in camelCase.
- All variables should follow camelCasing convention
TODO - naming for constant variables, model names etc needs to be defined.
- Property names should be in camelCase
TODO Guidelines goes here. These should include following -
- Indentation
..* Use spaces instead of tabs
..* Indentation size = 4 spaces - Braces
..1. Starting brace goes on the same line. - White spaces
..1. Space after comma in multiple variable declaration
..2. Space before an opening brace
..3. Space after a comma in function parameter - Blank lines
- New lines
- Control statements
- Line wrapping
- Comments
e.g. User map () function to iterate over array instead of using _.forEach ()
E.g. when a mixin is applied to a model, it attaches the code to the model. This code should further not check if mixin is applied or not.
e.g.
var autoscope = ctx.Model.definition.settings.autoscope ? ctx.Model.definition.settings.autoscope : [];
In above statement ctx.Model.definition.settings.autoscope check can be avoided by initializing autoscope parameter to an empty array ([]) in the model constructor.
e.g.
if (autoscope && autoscope.length) {
}
since we have initialized autoscope such if
condition is not needed.
Create and use multiple types of Error objects like EvBusinessError, EvSystemError instead of generic Error. EvBusinessError can further be of type e.g. DataPersonalizationError
e.g. instead /Application API accepting commands like 'create', 'start', 'stop' in a single API, create individual Apis - /Application/id/start, /Application/id/stop etc.
Individual APIs gives better control over ACLs, Monitoring and metering.
e.g. Instead of using 'before save' have a constant variable and use it.
Instead capture the value of nested object in a variable for further use.