Files
fail/doc/coding-style.txt
hsc be7b519346 coding style update
- Adhering to itself now (English!).
- Removed Adrian's private preferences for weird indentation rules.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1309 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
2012-06-06 14:27:14 +00:00

81 lines
3.1 KiB
Plaintext

Coding Style for Fail*
======================
You may violate/break any of the following rules if you have a good reason to
do so, e.g., if readability is notably enhanced.
- Language (comments, SVN commit messages, "temporary" stuff): English
(without exception)
- Naming conventions:
* Source files: .cc (Source), .hpp (Header), .ah (Aspect Header), MixedCase
* Namespaces: lowercase
* Classes: MixedCase, starting with uppercase letter
* Public members: MixedCase, starting with lowercase letter
* Private & protected members: starting with "m_"
* Global Variables: starting with "g_"
* Preprocessor macros: uppercase
- Include guard for MyFooBar.hpp: __MY_FOO_BAR_HPP__
* Constant variables: uppercase
* (no convention for local variables)
* typedefs: lowercase, underscores (good_name_t)
- Comments:
* Doxygen comments:
- In detail for all public members (parameters, return value, side
effects, ...)
- (At least) Briefly for private/protected members
- At the top of each (aspect) header file: @brief
- For each complex data type (and its elements)
* Explain *nontrivial* program logic not only by describing the "what's
happening here", but also the "why are we doing it this way".
* Use "normal" C/C++ comments within functions (//, /**/).
* No author names, creation dates, change logs etc. in source files.
That's why we're using a VCS.
- Formatting:
* Indentation: 1 tab (tabstop at 4 spaces)
- may be relaxed / mixed with spaces for better readability of
multi-line statements, e.g.:
<TAB>cout << "The counter value is: "
<TAB> << value;
<TAB>if (first_looong_condition &&
<TAB> second_looong_condition) {
<TAB><TAB>...
* Preprocessor directives start in column 1.
* Max. line length: 100 characters.
* "public"/"private"/"protected" has the same identation as its surrounding
"class Foo" statement (we'd waste one indentation level for every class
definition otherwise):
class Foo {
public:
<TAB>void doSomething();
}
Similarly (and for the same reason) for namespaces and switch/case
statements:
switch (foo) {
case 1:
<TAB>...
}
* Compound statements (blocks): <Space>+'{' in the same line as its
governing control structure (if, while, for, switch, try) or
namespace/class definition:
if (something) {
<TAB>...
}
* Function definitions are an exception to this ('{' in a new line):
Definition: | Declaration:
void myFunction(int i) | void myFunction(int i);
{ |
<TAB>... |
} |
* Control structure tokens ("if", "try", ...) are followed by a single
space for better disambiguation from function definitions:
if (...) {
<TAB>...
} else if (...) {
<TAB>...
} else {
<TAB>...
}