aboutsummaryrefslogtreecommitdiff
path: root/doc/Coding_style
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-03 12:46:32 (GMT)
committerfluxgen <fluxgen>2002-12-03 12:46:32 (GMT)
commitb25fd24b490f14a5e3f02a68d7bda60b90aa1253 (patch)
treec8ab64853862785b7af94d0fbf0e45abe397f89f /doc/Coding_style
parent64c280e6e2336c29332e37d0cc9809656786fcd6 (diff)
downloadfluxbox_pavel-b25fd24b490f14a5e3f02a68d7bda60b90aa1253.zip
fluxbox_pavel-b25fd24b490f14a5e3f02a68d7bda60b90aa1253.tar.bz2
update
Diffstat (limited to 'doc/Coding_style')
-rw-r--r--doc/Coding_style114
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 @@
1Use hard tab for indentation. (size 4) 1Use 4 space indent
2Spaces between "," 2Spaces between ","
3ex: 1, 2, 3, 4 3ex: 1, 2, a, 4
4 4
5if/else-statements: 5if/else-statements:
6An else clause is joined to any preceding close curly brace 6An else clause is joined to any preceding close curly brace
7that is part of its if. 7that is part of its if.
8 8
9if (....) { 9if (....) {
10 .... 10 ....
11} else { 11} else {
12 .... 12 ....
13} 13}
14if the line needs to be splited up, right after an if-statement 14if the line needs to be splited up, right after an if-statement
15use { and }, so its clear when the if-statement ends. 15use { and }, so its clear when the if-statement ends.
16ex: 16ex:
17if (...) { 17if (...) {
18 function(....., 18 function(.....,
19 ......, .... ); 19 ......, .... );
20} 20}
21 21
22This is ok: 22This is ok:
23if (...) 23if (...)
24 shortline(...); 24 shortline(...);
25 25
26 26
27while-statement: 27while-statement:
28 28
29while (...) { 29while (...) {
30 .... 30 ....
31} 31}
32 32
33for-statement: 33for-statement:
34 34
35for (init; condition; update) { 35for (init; condition; update) {
36 .... 36 ....
37} 37}
38 38
39for (longinit; 39for (longinit;
40 longcondition; 40 longcondition;
41 longupdate ) { 41 longupdate ) {
42 .... 42 ....
43} 43}
44alt form: 44alt form:
45 45
46init; 46init;
47for (; condition; update) { 47for (; condition; update) {
48 .... 48 ....
49} 49}
50 50
51do-statement: 51do-statement:
52 52
53do { 53do {
54 .... 54 ....
55} while (...); 55} while (...);
56 56
57switch-statement: 57switch-statement:
@@ -60,23 +60,19 @@ Enum values is an exception, they should not have a default: , when you add
60new values to an enum you might forget to add them to switch statement. 60new values to an enum you might forget to add them to switch statement.
61 61
62switch (...) { 62switch (...) {
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
76goto-statement:
77DONT USE IT!
78
79
80Include guards: 76Include guards:
81For files with namespace: 77For 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.
112functions: 108functions:
113The name starts with a lowercase and then a uppercase for name separation: 109The name starts with a lowercase and then a uppercase for name separation:
114void functionWithAName(...) { 110void functionWithAName(...) {
115 ...; 111 ...;
116} 112}
117 113
114Use Javadoc style for function description (see www.doxygen.org)
118Function comments: 115Function 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*/
123void functionDoes(...) { 121void functionDoes(...) {
124 122
125} 123}
126Comments:
127Use // on few line comments.
128Use
129/*
130...
131...
132*/
133when there are a lot to comment
134 124
135Class: 125Class:
136Order: public, protected and then private 126Order: public, protected and then private
@@ -141,27 +131,27 @@ manipulator and accessors categories.
141 131
142class Classname:public AnotherClass { 132class Classname:public AnotherClass {
143public: 133public:
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
152protected: 142protected:
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
159private: 149private:
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.
180try/catch-statement: 170try/catch-statement:
181 171
182try { 172try {
183 ....; 173 ....;
184} catch (...) { 174} catch (...) {
185 ....; 175 ....;
186} 176}
187 177
188Variables: 178Variables: