Coding conventions
Try to write the code to be easy readable for newcomer.Variables
- Variable names are lower case.
- Variables names use underscores as word separators.
- First word of each variable name is type of the variable (with three exceptions).
- If variable is an pointer or any special pointer (such as smart pointer) then it begins with “ptr_” or “ref_” or with any string which describes pointer.
- If variable is member of some class then it begins with “m_” string.
Data Types
- i (integer)
- f (float)
- w (word)
- dw (double word)
- d (double)
- b (bool)
- str (string)
- ch (char)
- v (vector)
- q (quaternion)
- mat (matrix)
- arr (array)
- map (map)
etc.
Classes
- Class name consists from these parts: <group>_[<subgroup>_]<name>.
- Group is a logical group into which the object belongs.
- Subgroup is logical part of group.
- Group and subgroup have two or three characters.
- Group and subgroup are upper case.
- Name of the object (after group and subgroup) are written in this shape: first character of each word is upper case, remaining characters are lower case, words are not separated.
- First characters of abstract class from which all classes in subgroup inherits should assemble subgroup.
Methods
- First word in method name is in lower case, remaining words begin with upper case and other characters in the word are lower case.
- First word is always verb!
- Whenever we want to set up or retrieve some object parameters or protected attributes we use “set” and “get” as a verb with one exception.
- If we want to detect bool attribute we use “is”.
- We are using set, get and is even if it is not grammatically correct. Usage of this dogma is on your consideration.
- If we want to divide one huge method into several methods (due lucidity) we use underscore at the beginning of the method name. We use this rule only in case when method with underscore is used only at one place as a part of big task. Such method must be protected or private.
Structures
- Standalone structures use same naming convention as classes.
- Structures have only public attributes. Whenever you feel a need to make some attribute of the structure to be protected you could be sure you have to do class instead.
Enumerators
- Enums are upper case.
- Enums use underscores as word separators.
- With these exceptions enums use same naming conventions as classes or structures.
Defines
- Defines use naming conventions as enums.
Embedded classes and structures
- If you want to declare class, structure or enum inside another class then do not use group and subgroup in the name.