Project

General

Profile

CodingRules » History » Version 7

Jules Waldhart, 2016-06-17 14:59
logging and pullrequest instructions

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 7 Jules Waldhart
h2. Console output and logging
10
11
You must use logm3d. std::cout must not appear in any pullrequest. See "the documentation":https://wiki.laas.fr/robots/libmove3d/DeveloperInstructions
12
13 4 Jules Waldhart
h2. Naming
14 1 Jules Waldhart
15 4 Jules Waldhart
h3. Classes, attributes, variables
16
17 3 Jules Waldhart
* ClassesAreCamelCase with first letter capital, also are all types (typedef, enum, struct,...)
18
* methodsAreCamelCase with first letter lowercase
19 6 Jules Waldhart
* _privateAttributeStartWithUnderscore and is camelCase
20 1 Jules Waldhart
* localVariable or local_variable, first letter lowercase
21
* 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)@
22
23 4 Jules Waldhart
h3. Enums
24
25 5 Jules Waldhart
Put enums in an existing namespace or class, and/or *create a struct and put it inside*.
26
That struct can also contain methods to convert to/from string and other types.
27
Enums and their container struct are CapitalCamelCase, as their values (see example).
28 1 Jules Waldhart
29 6 Jules Waldhart
Google coding style recommends using @MACRO_STYLE@ for enum values, or constant style, ie. starting with a "@k@": @kRobot@. It can be accepted, stay consistent within a "module"/class of move3d.
30
31 1 Jules Waldhart
<pre>
32 4 Jules Waldhart
struct RobotType{
33 5 Jules Waldhart
   enum Value {Robot, Human, Object, NotDefined};
34 4 Jules Waldhart
   std::string toString(Value v);
35
   ...
36
}
37 1 Jules Waldhart
</pre>
38 6 Jules Waldhart
39
40 4 Jules Waldhart
41
h2. Unimplemented stuff
42 3 Jules Waldhart
43 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)
44 1 Jules Waldhart
* but mainly, avoid to commit unimplemented functions.
45 7 Jules Waldhart
46
h2. Pull-requests
47
48
h3. History
49
50
Keep the history clean: when a pull-request is made of several commits, something that do not appear in the final state should not appear in any commit. Example:
51
52
bad pull-request
53
<pre>
54
commit: A
55
   creating feature X an Y
56
57
diff file.cpp
58
+ bool funcX() {...}
59
+ bool funcY() {...}
60
61
commit: B
62
   update in feature X and Y
63
64
diff file.cpp
65
- bool funcX() {...}
66
- bool funcY() {...}
67
+ bool funcX() {...;...}
68
+ bool funcY() {...;...}
69
70
commit: C
71
    remove feature X
72
73
diff file.cpp
74
-bool funcX() {...;...}
75
</pre>
76
77
The reviewer will review the code of funcX() in commit A, the changes made in commit B, and will be really disappointed when reading commit C. Moreover, it is useless to have such things in the history.