-
Use one tab per indentation level (and use an editor that does not
replace tabs). Use only tabs at the beginning of a line and
not to indent comments.
- No spaces after an open or before a closing bracket.
- One space after a comma, an ``if'' or an ``switch'':
if ((1 == count) || (5 == calcMax(7, 19)))
{
...
}
- Lines should not exceed 78 characters with a tab width of 2.
(not only because it's easier
to get the code on screen, but because of printing the source code
(and diff's) gets much easier).
- Only one variable declaration per line (except they are no
pointers and they have really very much in common)
- The '&' and '*' tokens should be adjacent to the type, not the name:
int* vertexIndices;
- Each ``if'' statement has to be bracketed with no exception.
if (condition) // Comment
{
}
else if (condition) // Comment
{
}
else // Comment
{
}
- Falling through a case statement into the next case statement shall be
permitted as long as a comment is included.
The default case should always be present and trigger an error if it should
not be reached, yet is reached.
switch (...)
{
case 1:
...
// FALL THROUGH
case 2:
{
int v;
...
}
break;
default:
// Error?
}
- The class-member declaration in the .h files has to use the following
template:
/**
* Documentation (see documentation section)
*/
class ClassName
{
public:
/** all public variable declarations (static variables at the
* beginning) */
...
protected:
/** all protected variable declarations */
...
private:
/** all private variable declarations */
...
//------------------------ [ Methods ] -------------------------
public:
...
protected:
...
private:
...
}
- The implementation of the methods in the .cpp files has to be in the
same order as the declaration in the .h file but with larger seperators:
/****************************************************************
* [Public/Protected/Private] Methods
****************************************************************/
- The method implementations in the .cpp file should be seperated by
at least two newlines.
- For the sake of clarity there should be separators in large code files.
These separators can optional include a short description:
//-------------- [short description or section name] ------------
There will be an astyle