Changes
Page history
Update Coding rules
authored
Jul 03, 2019
by
Julien Leclerc
Show whitespace changes
Inline
Side-by-side
Coding-rules.md
View page @
a6ec2c65
Here are gather some good practice for coding:
Here are gathered some good practice for coding.
General rules:
*
Add comments to the code (ideally, almost each line should be commented)
*
Always use "const" keywords where needed
*
Promote complete names when possible for the variables, in particular when used in several places in the code (example: fv => localPorosity)
*
Variables are named using "camel case" rule (e.g. exampleOfVariableName)
Name rules:
*
Class name start with an uppercase (e.g. Example)
*
Internal variables of a class start with an underscore and a lowercase (e.g. _example)
*
Class functions start with a lowercase (e.g. example)
*
Functions "get/set":
*
getRefToExample() : can be used or set by reference a variable value that exists (or copy-paste its value);
*
getConstRefToExample() : idem but in read-only access;
*
getExample : use it when you want to return an object that may be not exist;
*
setExample : set a value that may be not exist or through a more complex function than just an assignment