diff options
author | fluxgen <fluxgen> | 2002-12-03 12:46:32 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-12-03 12:46:32 (GMT) |
commit | b25fd24b490f14a5e3f02a68d7bda60b90aa1253 (patch) | |
tree | c8ab64853862785b7af94d0fbf0e45abe397f89f | |
parent | 64c280e6e2336c29332e37d0cc9809656786fcd6 (diff) | |
download | fluxbox-b25fd24b490f14a5e3f02a68d7bda60b90aa1253.zip fluxbox-b25fd24b490f14a5e3f02a68d7bda60b90aa1253.tar.bz2 |
update
-rw-r--r-- | doc/Coding_style | 114 |
1 files 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 @@ | |||
1 | Use hard tab for indentation. (size 4) | 1 | Use 4 space indent |
2 | Spaces between "," | 2 | Spaces between "," |
3 | ex: 1, 2, 3, 4 | 3 | ex: 1, 2, a, 4 |
4 | 4 | ||
5 | if/else-statements: | 5 | if/else-statements: |
6 | An else clause is joined to any preceding close curly brace | 6 | An else clause is joined to any preceding close curly brace |
7 | that is part of its if. | 7 | that is part of its if. |
8 | 8 | ||
9 | if (....) { | 9 | if (....) { |
10 | .... | 10 | .... |
11 | } else { | 11 | } else { |
12 | .... | 12 | .... |
13 | } | 13 | } |
14 | if the line needs to be splited up, right after an if-statement | 14 | if the line needs to be splited up, right after an if-statement |
15 | use { and }, so its clear when the if-statement ends. | 15 | use { and }, so its clear when the if-statement ends. |
16 | ex: | 16 | ex: |
17 | if (...) { | 17 | if (...) { |
18 | function(....., | 18 | function(....., |
19 | ......, .... ); | 19 | ......, .... ); |
20 | } | 20 | } |
21 | 21 | ||
22 | This is ok: | 22 | This is ok: |
23 | if (...) | 23 | if (...) |
24 | shortline(...); | 24 | shortline(...); |
25 | 25 | ||
26 | 26 | ||
27 | while-statement: | 27 | while-statement: |
28 | 28 | ||
29 | while (...) { | 29 | while (...) { |
30 | .... | 30 | .... |
31 | } | 31 | } |
32 | 32 | ||
33 | for-statement: | 33 | for-statement: |
34 | 34 | ||
35 | for (init; condition; update) { | 35 | for (init; condition; update) { |
36 | .... | 36 | .... |
37 | } | 37 | } |
38 | 38 | ||
39 | for (longinit; | 39 | for (longinit; |
40 | longcondition; | 40 | longcondition; |
41 | longupdate ) { | 41 | longupdate ) { |
42 | .... | 42 | .... |
43 | } | 43 | } |
44 | alt form: | 44 | alt form: |
45 | 45 | ||
46 | init; | 46 | init; |
47 | for (; condition; update) { | 47 | for (; condition; update) { |
48 | .... | 48 | .... |
49 | } | 49 | } |
50 | 50 | ||
51 | do-statement: | 51 | do-statement: |
52 | 52 | ||
53 | do { | 53 | do { |
54 | .... | 54 | .... |
55 | } while (...); | 55 | } while (...); |
56 | 56 | ||
57 | switch-statement: | 57 | switch-statement: |
@@ -60,23 +60,19 @@ Enum values is an exception, they should not have a default: , when you add | |||
60 | new values to an enum you might forget to add them to switch statement. | 60 | new values to an enum you might forget to add them to switch statement. |
61 | 61 | ||
62 | switch (...) { | 62 | switch (...) { |
63 | case ...: | 63 | case ...: |
64 | ...; | 64 | ...; |
65 | break; | 65 | break; |
66 | case ...: { | 66 | case ...: { |
67 | ...; | 67 | ...; |
68 | } break; | 68 | } break; |
69 | case ...: | 69 | case ...: |
70 | ...; | 70 | ...; |
71 | default: | 71 | default: |
72 | ....; | 72 | ....; |
73 | break; | 73 | break; |
74 | } | 74 | } |
75 | 75 | ||
76 | goto-statement: | ||
77 | DONT USE IT! | ||
78 | |||
79 | |||
80 | Include guards: | 76 | Include guards: |
81 | For files with namespace: | 77 | For files with namespace: |
82 | #ifndef NAMESPACE_FILENAME_HH | 78 | #ifndef NAMESPACE_FILENAME_HH |
@@ -112,25 +108,19 @@ cryptic and sometime make it hard to debug. | |||
112 | functions: | 108 | functions: |
113 | The name starts with a lowercase and then a uppercase for name separation: | 109 | The name starts with a lowercase and then a uppercase for name separation: |
114 | void functionWithAName(...) { | 110 | void functionWithAName(...) { |
115 | ...; | 111 | ...; |
116 | } | 112 | } |
117 | 113 | ||
114 | Use Javadoc style for function description (see www.doxygen.org) | ||
118 | Function comments: | 115 | Function comments: |
119 | // This do that and that | 116 | /** |
120 | // Returns this on success else | 117 | This do that and that |
121 | // this on failure. | 118 | @return this on success else this on failure. |
122 | // TODO: if there is something to do. | 119 | TODO: if there is something to do. |
120 | */ | ||
123 | void functionDoes(...) { | 121 | void functionDoes(...) { |
124 | 122 | ||
125 | } | 123 | } |
126 | Comments: | ||
127 | Use // on few line comments. | ||
128 | Use | ||
129 | /* | ||
130 | ... | ||
131 | ... | ||
132 | */ | ||
133 | when there are a lot to comment | ||
134 | 124 | ||
135 | Class: | 125 | Class: |
136 | Order: public, protected and then private | 126 | Order: public, protected and then private |
@@ -141,27 +131,27 @@ manipulator and accessors categories. | |||
141 | 131 | ||
142 | class Classname:public AnotherClass { | 132 | class Classname:public AnotherClass { |
143 | public: | 133 | public: |
144 | //1. public enums, structs | 134 | //1. public enums, structs |
145 | 135 | ||
146 | //2. constructors and destructor | 136 | //2. constructors and destructor |
147 | 137 | ||
148 | //3. manipulators | 138 | //3. manipulators |
149 | 139 | ||
150 | //4. accessors | 140 | //4. accessors |
151 | 141 | ||
152 | protected: | 142 | protected: |
153 | //1. enums, structs | 143 | //1. enums, structs |
154 | 144 | ||
155 | //2. functions | 145 | //2. functions |
156 | 146 | ||
157 | //3. variables | 147 | //3. variables |
158 | 148 | ||
159 | private: | 149 | private: |
160 | //1. enums, structs | 150 | //1. enums, structs |
161 | 151 | ||
162 | //2. functions | 152 | //2. functions |
163 | 153 | ||
164 | //3. variables | 154 | //3. variables |
165 | }; | 155 | }; |
166 | 156 | ||
167 | 157 | ||
@@ -180,9 +170,9 @@ We don't want to force the other files, that include the file, a namespace. | |||
180 | try/catch-statement: | 170 | try/catch-statement: |
181 | 171 | ||
182 | try { | 172 | try { |
183 | ....; | 173 | ....; |
184 | } catch (...) { | 174 | } catch (...) { |
185 | ....; | 175 | ....; |
186 | } | 176 | } |
187 | 177 | ||
188 | Variables: | 178 | Variables: |