From b25fd24b490f14a5e3f02a68d7bda60b90aa1253 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 3 Dec 2002 12:46:32 +0000 Subject: update --- doc/Coding_style | 114 +++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 62 deletions(-) diff --git a/doc/Coding_style b/doc/Coding_style index 0c10170..47bd173 100644 --- a/doc/Coding_style +++ b/doc/Coding_style @@ -1,57 +1,57 @@ -Use hard tab for indentation. (size 4) +Use 4 space indent Spaces between "," -ex: 1, 2, 3, 4 +ex: 1, 2, a, 4 if/else-statements: An else clause is joined to any preceding close curly brace that is part of its if. if (....) { - .... + .... } else { - .... + .... } if the line needs to be splited up, right after an if-statement use { and }, so its clear when the if-statement ends. ex: if (...) { - function(....., - ......, .... ); + function(....., + ......, .... ); } This is ok: if (...) - shortline(...); + shortline(...); while-statement: while (...) { - .... + .... } for-statement: for (init; condition; update) { - .... + .... } for (longinit; - longcondition; - longupdate ) { - .... + longcondition; + longupdate ) { + .... } alt form: init; for (; condition; update) { - .... + .... } do-statement: do { - .... + .... } while (...); 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. switch (...) { - case ...: - ...; - break; - case ...: { - ...; - } break; - case ...: - ...; - default: - ....; - break; + case ...: + ...; + break; + case ...: { + ...; + } break; + case ...: + ...; + default: + ....; + break; } -goto-statement: -DONT USE IT! - - Include guards: For files with namespace: #ifndef NAMESPACE_FILENAME_HH @@ -112,25 +108,19 @@ cryptic and sometime make it hard to debug. functions: The name starts with a lowercase and then a uppercase for name separation: void functionWithAName(...) { - ...; + ...; } +Use Javadoc style for function description (see www.doxygen.org) Function comments: -// This do that and that -// Returns this on success else -// this on failure. -// TODO: if there is something to do. +/** + This do that and that + @return this on success else this on failure. + TODO: if there is something to do. +*/ void functionDoes(...) { } -Comments: -Use // on few line comments. -Use -/* -... -... -*/ -when there are a lot to comment Class: Order: public, protected and then private @@ -141,27 +131,27 @@ manipulator and accessors categories. class Classname:public AnotherClass { public: - //1. public enums, structs - - //2. constructors and destructor - - //3. manipulators - - //4. accessors - + //1. public enums, structs + + //2. constructors and destructor + + //3. manipulators + + //4. accessors + protected: - //1. enums, structs - - //2. functions - - //3. variables + //1. enums, structs + + //2. functions + + //3. variables private: - //1. enums, structs - - //2. functions - - //3. variables + //1. enums, structs + + //2. functions + + //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 (...) { - ....; + ....; } Variables: -- cgit v0.11.2