Coding Guide
Last updated
Was this helpful?
Last updated
Was this helpful?
This style guide extends from the official and some aspects has been modified to suit our needs.
Git commits should follow the format:
[file/method/function changed]: (Fixes #num | Refs #num ) Your descriptive commit message
Note: #num is a pull or issue number.
For example:
[Imageprocessor]: Fixes #20 Add crop method
All changes are made in new branches and a pull request should be opened against the dev branch for review.
File names must be all lowercase and may be separated by dot .
For example:
We use two spaces for indentation. If you use a code editor like vscode
, you can set a default spaces to 2 instead of 4. We do not use Tab.
A file consist of the following, in order:
License or copyright information
ES import statements, if an ES module
The file’s source code
For example:
Class, interface, record, and typedef names are written in UpperCamelCase e.g ImageProcessor
. Type names are typically nouns or noun phrases. For example, Request, ImmutableList, or VisibilityMode.
Method names are written in lowerCamelCase e.g addNum
. Names for private methods must start with a trailing underscore e.g _startAddition
.
Method names are typically verbs or verb phrases. For example, sendMessage
or _stopProcess
. Getter and setter methods for properties are never required, but if they are used they should be named getFoo
(or optionally isFoo
or hasFoo
for booleans), or setFoo(value)
for setters.
Constant names use CONSTANT_CASE
: all uppercase letters, with words separated by underscores.
JSDoc is used on all classes, fields, functions/methods. The basic formatting of JSDoc blocks is as seen in this example:
We use for testing, and require contributors to follow a (TDD) approach where you write test to fail at first and then write the corresponding function to pass the test.