This commit is contained in:
fluxgen 2002-12-03 12:46:32 +00:00
parent 64c280e6e2
commit b25fd24b49

View file

@ -1,57 +1,57 @@
Use hard tab for indentation. (size 4) Use 4 space indent
Spaces between "," Spaces between ","
ex: 1, 2, 3, 4 ex: 1, 2, a, 4
if/else-statements: if/else-statements:
An else clause is joined to any preceding close curly brace An else clause is joined to any preceding close curly brace
that is part of its if. that is part of its if.
if (....) { if (....) {
.... ....
} else { } else {
.... ....
} }
if the line needs to be splited up, right after an if-statement if the line needs to be splited up, right after an if-statement
use { and }, so its clear when the if-statement ends. use { and }, so its clear when the if-statement ends.
ex: ex:
if (...) { if (...) {
function(....., function(.....,
......, .... ); ......, .... );
} }
This is ok: This is ok:
if (...) if (...)
shortline(...); shortline(...);
while-statement: while-statement:
while (...) { while (...) {
.... ....
} }
for-statement: for-statement:
for (init; condition; update) { for (init; condition; update) {
.... ....
} }
for (longinit; for (longinit;
longcondition; longcondition;
longupdate ) { longupdate ) {
.... ....
} }
alt form: alt form:
init; init;
for (; condition; update) { for (; condition; update) {
.... ....
} }
do-statement: do-statement:
do { do {
.... ....
} while (...); } while (...);
switch-statement: switch-statement:
@ -60,23 +60,19 @@ Enum values is an exception, they should not have a default: , when you add
new values to an enum you might forget to add them to switch statement. new values to an enum you might forget to add them to switch statement.
switch (...) { switch (...) {
case ...: case ...:
...; ...;
break; break;
case ...: { case ...: {
...; ...;
} break; } break;
case ...: case ...:
...; ...;
default: default:
....; ....;
break; break;
} }
goto-statement:
DONT USE IT!
Include guards: Include guards:
For files with namespace: For files with namespace:
#ifndef NAMESPACE_FILENAME_HH #ifndef NAMESPACE_FILENAME_HH
@ -112,25 +108,19 @@ cryptic and sometime make it hard to debug.
functions: functions:
The name starts with a lowercase and then a uppercase for name separation: The name starts with a lowercase and then a uppercase for name separation:
void functionWithAName(...) { void functionWithAName(...) {
...; ...;
} }
Use Javadoc style for function description (see www.doxygen.org)
Function comments: Function comments:
// This do that and that /**
// Returns this on success else This do that and that
// this on failure. @return this on success else this on failure.
// TODO: if there is something to do. TODO: if there is something to do.
*/
void functionDoes(...) { void functionDoes(...) {
} }
Comments:
Use // on few line comments.
Use
/*
...
...
*/
when there are a lot to comment
Class: Class:
Order: public, protected and then private Order: public, protected and then private
@ -141,27 +131,27 @@ manipulator and accessors categories.
class Classname:public AnotherClass { class Classname:public AnotherClass {
public: public:
//1. public enums, structs //1. public enums, structs
//2. constructors and destructor //2. constructors and destructor
//3. manipulators //3. manipulators
//4. accessors //4. accessors
protected: protected:
//1. enums, structs //1. enums, structs
//2. functions //2. functions
//3. variables //3. variables
private: private:
//1. enums, structs //1. enums, structs
//2. functions //2. functions
//3. variables //3. variables
}; };
@ -180,9 +170,9 @@ We don't want to force the other files, that include the file, a namespace.
try/catch-statement: try/catch-statement:
try { try {
....; ....;
} catch (...) { } catch (...) {
....; ....;
} }
Variables: Variables: