Macaw-Movies/Development/Code Rules: Difference between revisions
Appearance
Line 5: | Line 5: | ||
=== Variables === | === Variables === | ||
* Abreviations are not tolerated anywhere in the code. All names must be as explicit as possible | * Abreviations are not tolerated anywhere in the code. All names must be as explicit as possible | ||
* members start with | * members start with <code>m_</code> | ||
* local variables start with | * local variables start with <code>l_</code> | ||
* function parameter names do not have a specific prefix | * function parameter names do not have a specific prefix | ||
* global variables are prohibited, the few accepted are capitalized | * global variables are prohibited, the few accepted are capitalized |
Revision as of 13:31, 23 April 2015
Naming
- English is used for all names (class, function, variable…)
- camelCase is used for all names
Variables
- Abreviations are not tolerated anywhere in the code. All names must be as explicit as possible
- members start with
m_
- local variables start with
l_
- function parameter names do not have a specific prefix
- global variables are prohibited, the few accepted are capitalized
- class names start with a capital letter
Functions
- blank line before calling return
- blank line between two logical blocs
Conditions
The following rules sould be followed (1 space after key word, 1 between condition and curly bracket).
if (variable > 0) { ...do something... } else if (variable == 0) { ...do something else... } else { ...do something else... }
If there is more conditions to fulfill:
if (cond1 & cond2) { ...do something... }
For the switch/case:
switch (var) { case 1: fct(); break; case 2: otherFct(); break; }