1 Coding style guidelines for DDE
2 ###############################
8 ! * \brief Short description of the file
9 ! * \author Original author
10 ! * \date Creation date
12 ! * Some more detailed description. This is optional.
19 * First character of class names uppercase, any other characters lowercase
20 * Function and variable names lower case
21 * 'Multi_word_identifiers' via underline
22 * 'CONSTANTS' upper case
23 * Private and protected members of a class begin with an '_'-character
24 * Accessor functions are named after their corresponding attributes:
27 ! * Request private member variable
29 ! int value() { return _value; }
32 ! * Set the private member variable
34 ! void value(int value) { _value = value; }
40 * Use one tab per indentation step. *Do not mix tabs and spaces!*
41 * Use no tabs except at the beginning of a line.
42 * Use spaces for alignment
44 See [http://electroly.com/mt/archives/000002.html] for a more detailed
47 This way, everyone can set his preferred tabsize in his editor
48 and the source code always looks good.
56 * Leave two empty lines between classes.
57 * Leave one empty line between member functions.
59 In implementation files:
61 * Leave two empty lines between functions.
67 * Braces after classnames and functions are placed at a new line:
78 except for single-line functions.
80 * All other occurrences of open braces (for 'if', 'while', 'for' etc.) are at the end of a line:
88 * Surprisingly, one-line functions should be written on one line.
89 Typically, this applies for accessor functions.
90 If slightly more space than one line is needed, indent as follows:
92 ! int heavy_computation(int a, int lot, int of, int args) {
93 ! return a + lot + of + args; }
102 Each public or protected (but no private) function in a header-file should be
103 prepended by a header as follows:
106 ! * Short description
108 ! * \param a Meaning of parameter a
110 ! * \returns Meaning of return value
112 ! * More detailed information about the function. This is optional.
115 In the implementation files, only private functions should feature such
122 ! /* use this syntax for single line comments */
124 A single-line comment should be prepended by an empty line.
125 Single-line comments should be short - no complete sentences. Use lower-case.
127 C++-style comments ('//') should only be used for temporarily commenting-out
128 code. Such commented-out garbage is easy to 'grep' and there are handy
129 'vim'-macros available for creating and removing such comments.
132 Variable descriptions
133 ~~~~~~~~~~~~~~~~~~~~~
135 Use the same syntax as for single-line comments. Insert two or more
136 spaces before your comment starts.
138 ! int size; /* in kilobytes */
144 Multi-line comments are more detailed descriptions in the form of
146 A multi-line comment should be enclosed by empty lines.
149 ! * This is some tricky
150 ! * algorithm that works
155 The first and last line of a multi-line comment contain no words.
161 For structuring your source code, you can entitle the different
162 parts of a file like this:
166 ! /********************
167 ! ** Event handlers **
168 ! ********************/
171 Note the two stars at the left and right. There are two of them to
172 make the visible width of the border match its height (typically,
173 characters are ca. twice as high as wide).
175 A source-code block header represents a headline for the following
176 code. To couple this headline with the following code closer than
177 with previous code, leave two empty lines above and one empty line
178 below the source-code block header.
181 Order of public, protected, and private blocks
182 ==============================================
184 For consistency reasons, use the following class layout:
195 Typically, the private section contains member variables that are used
196 by public accessor functions below. In this common case, we only reference
197 symbols that are defined above as it is done when programming plain C.
199 Leave one empty line (or a line that contains only a brace) above and below
200 a 'private', 'protected', or 'public' label. This also applies when the
201 label is followed by a source-code block header.