Project

General

Profile

CodingRules » History » Version 5

Jules Waldhart, 2016-05-30 16:55
more about enums 2

1 1 Jules Waldhart
h1. Coding Rules
2
3 4 Jules Waldhart
*Table of Contents*
4
5
{{toc}}
6
7 1 Jules Waldhart
An unordered list of stuff we would like devs to follow
8
9 4 Jules Waldhart
h2. Naming
10 1 Jules Waldhart
11 4 Jules Waldhart
h3. Classes, attributes, variables
12
13 3 Jules Waldhart
* ClassesAreCamelCase with first letter capital, also are all types (typedef, enum, struct,...)
14
* methodsAreCamelCase with first letter lowercase
15
* _attributeStartWithUnderscore and is camelcase
16 1 Jules Waldhart
* localVariable or local_variable, first letter lowercase
17
* avoid calling @a=function(1.0,6,false,true)@, declare local variables with descriptive name for the parameters: @a=function(step_size,iteration_nb,enable_XYZ,multi_thread)@
18
19 4 Jules Waldhart
h3. Enums
20
21 5 Jules Waldhart
Put enums in an existing namespace or class, and/or *create a struct and put it inside*.
22
That struct can also contain methods to convert to/from string and other types.
23
Enums and their container struct are CapitalCamelCase, as their values (see example).
24 4 Jules Waldhart
25 1 Jules Waldhart
<pre>
26 4 Jules Waldhart
struct RobotType{
27 5 Jules Waldhart
   enum Value {Robot, Human, Object, NotDefined};
28 4 Jules Waldhart
   std::string toString(Value v);
29
   ...
30
}
31
</pre>
32
33
h2. Unimplemented stuff
34 3 Jules Waldhart
35 2 Jules Waldhart
* not implemented functions: put an @assert(false);@ in it, it will abort in debug mode, and do nothing in release. (instead of a print or whatever, which is totally unclear)
36 1 Jules Waldhart
* but mainly, avoid to commit unimplemented functions.