forked from openmeeg/openmeeg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoding_guidelines.txt
100 lines (90 loc) · 3.39 KB
/
coding_guidelines.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Contribution rules
==================
For developers wishing to contribute in OpenMEEG, there are several coding
rules we have fixed to have an homogeneous source code. Rules are the
following :
- namings :
- english is used for every class names / variable names, function names...
- should it be in class names, functions, variables or whatever,
abbreviations are not tolerated. All the names have to be as explicit as
possible (the code is harder to write if you don't take advantage of
automatic completion, but it is times easier to read for people who did
not write this code !)
- namespace names are lower case
- class names start with an upper case character
- variables start with a lower case character
- member variables start with m_
- global variables are prohibited
(please contact the dev coordinator if this is necessary in your case)
- function names do not have prefix, start with a lower case character and
use upper case character for each new word (CamelCase : http://en.wikipedia.org/wiki/CamelCase)
- for and if / else blocks always have curly brackets,
even if only one call is to be done
- english is used for the documentation of the code
- code is documented with doxygen (http://www.stack.nl/~dimitri/doxygen/)
- implementation is documented for complex things with or without doxygen
- redundant include should be avoided thanks to #ifndef #define #endif in the
begining/end of the header files.
Ex : MyFile.h should be protected using
#ifndef MYFILE_H
#define MYFILE_H
/* Code */
#endif
- 'using namespace' directives shall not be used in header files
- tabs ('\t') are prohibited and are replaced with 4 spaces
This is a sample of OpenMEEG-compliant code illustrating these rules :
/**
* \file MyClass.h
* \author me
* \date today
* \brief a sample file containing MyClass class
*
* This sample file contains the definition of the
* MyClass class blah blah more details...
*/
namespace myclassnamespace // use namespace if necessary
{
/**
* \class MyClass
* \author me
* \date today
* \brief short-blah
*
* Detailed blah blah
*/
class MyClass
{
public:
/**
* \function sampleFunction
* \param inputValue[in] : blah
* \param outputValue[out] : blah
* \return blah blah
* \brief short-blah
*
* Detailed blah blah
*/
bool sampleFunction( int inputValue, int& outputValue )
{
int counter = 0;
for (int i = 0; i < inputValue; ++i) {
counter = counter + i;
}
if(counter > 50) {
outputValue = counter;
return true;
}
return false;
}
/**
* \function content
* \return blah blah
* \brief short-blah
*
* Detailed blah blah
*/
int content() const { return m_content; };
private:
int m_content;
};
};