summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-07-23 16:10:49 (GMT)
committerfluxgen <fluxgen>2002-07-23 16:10:49 (GMT)
commit012741f7e867c1e985e64af7ad1f1f5d4d39368b (patch)
treefebe76c9897ea060df2bd7e73778563793ee0805
parent4bc5d80ba7da019cfeeded6e3fc75bece963a49d (diff)
downloadfluxbox_lack-012741f7e867c1e985e64af7ad1f1f5d4d39368b.zip
fluxbox_lack-012741f7e867c1e985e64af7ad1f1f5d4d39368b.tar.bz2
huge update
-rw-r--r--doc/Coding_style234
1 files changed, 194 insertions, 40 deletions
diff --git a/doc/Coding_style b/doc/Coding_style
index d57dcf1..0cd9211 100644
--- a/doc/Coding_style
+++ b/doc/Coding_style
@@ -1,58 +1,212 @@
1The coding style is almost the same as i blackbox. 1Use hard tab for indentation. (size 4)
2Instead of 2 spaces there is tab. 2Spaces between ","
3Use a tab size of 2 or 4 and you will be fine. 3ex: 1, 2, 3, 4
4 4
5if-statements: 5if/else-statements:
6 6An else clause is joined to any preceding close curly brace
7 if ( stuff ) 7that is part of its if.
8 function(stuff, more stuff, 8
9 more, even more); 9if (....) {
10 else 10 ....
11 morefunction( stuff, more stuff 11} else {
12 stuff, 12 ....
13 stuff, 13}
14 stuff); 14if the line needs to be splited up, right after an if-statement
15
16if the functionline needs to be split up, like above, right after an if-statement
17use { and }, so its clear when the if-statement ends. 15use { and }, so its clear when the if-statement ends.
18It should look like this 16ex:
17if (...) {
18 function(.....,
19 ......, .... );
20}
19 21
20 if ( stuff ) { 22This is ok:
21 function(stuff, more stuff, 23if (...)
22 more, even more); 24 shortline(...);
23 } else { 25
24 morefunction( stuff, more stuff 26
25 stuff, 27while-statement:
26 stuff, 28
27 stuff); 29while (...) {
28 } 30 ....
29 31}
30If a line need to be splited in an if-statement then it should use two 32
31tab for indent next row in if-statement like this: 33for-statement:
34
35for (init; condition; update) {
36 ....
37}
38
39for (longinit;
40 longcondition;
41 longupdate ) {
42 ....
43}
44alt form:
45
46init;
47for (; condition; update) {
48 ....
49}
50
51do-statement:
52
53do {
54 ....
55} while (...);
56
57switch-statement:
58should always have a default value.
59Enum 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.
61
62switch (...) {
63 case ...:
64 ...;
65 break;
66 case ...: {
67 ...;
68 } break;
69 case ...:
70 ...;
71 default:
72 ....;
73 break;
74}
75
76goto-statement:
77DONT USE IT!
78
79
80Include guards:
81For files with namespace:
82#ifndef NAMESPACE_FILENAME_HH
83#define NAMESPACE_FILENAME_HH
84....
85
86#endif //NAMESPACE_FILENAME_HH
87<eof>
88
89Without namespace:
90#ifndef FILENAME_HH
91#define FILENAME_HH
92....
93
94#endif //FILENAME_HH
95
96<eof>
32 97
33 if ( longline && longline && longling && 98preprocessors:
34 longline && longline && longline) 99The # of all preprocessor commands must always be in column 1, and never use
35 funktion(); 100indentation for preprocessor directives
36 101
37The include guards: 102They should always have a // PREPROCESSOR to mark where they end
38FILENAME_HH 103#ifdef DEBUG
104...
105...
106#endif //DEBUG
39 107
108Don't use preprocessors for constants or macro-functions, they can be
109cryptic and sometime make it hard to debug.
110
111
112functions:
113The name starts with a lowercase and then a uppercase for name separation:
114void functionWithAName(...) {
115 ...;
116}
40 117
41Function comments: 118Function comments:
42//------------ function name --------
43// This do that and that 119// This do that and that
44// Returns this on success else 120// Returns this on success else
45// this on failure. 121// this on failure.
46// TODO: if there is something to do. 122// TODO: if there is something to do.
47//----------------------------------- 123void functionDoes(...) {
48type classname::function(...) { 124
125}
126Comments:
127Use // on few line comments.
128Use
129/*
130...
131...
132*/
133when there are a lot to comment
134
135Class:
136Order: public, protected and then private
137Class names always starts with a big letter.
138Class data members are prefixed by m_ , static data members are prefixed with s_ .
139Class member function will be organized according to creator,
140manipulator and accessors categories.
141
142class Classname:public AnotherClass {
143public:
144 //1. public enums, structs
145
146 //2. constructors and destructor
147
148 //3. manipulators
149
150 //4. accessors
151
152protected:
153 //1. enums, structs
154
155 //2. functions
156
157 //3. variables
158
159private:
160 //1. enums, structs
161
162 //2. functions
163
164 //3. variables
165};
166
167
168struct follows the class style.
169
170namespace:
171namespace TheName {
172...;
173...;
174}; //end namespace TheName
175
176Don't use "using namespace thenamespace;" in header-file
177We don't want to force the other files, that include the file, a namespace.
178
49 179
180try/catch-statement:
181
182try {
183 ....;
184} catch (...) {
185 ....;
50} 186}
51 187
188Variables:
189Avoid variables that contain mixtures of the numbers 0 & l and the letters O
190and 1, because they are hard to tell apart.
191Having a type name and a variable differing in only in case (such as:
192 String string;) is permitted, but discouraged.
193
194Use lowercase for variables and use _ to separate names, ex:
195int number_of_screens;
196int num_colors;
197
198
199All constants must be in Upper case letters.
52 200
53enums must be in uppercase letters and not in file scope: 201enums must be in uppercase letters and not in file scope:
54enum {WHITE, RED, BLUE}; 202enum {WHITE, RED, BLUE};
55 203
56Class data members are prefixed by m_ 204Other:
57Class member function will be organized accordning to creator, 205
58manipulator and accessor categories. 206if (strcmp(...) == 0) //good
207if (!strcmp()) //bad
208
209Don't create free-functions, encapsulate them in a namespace or a class
210and name filenames so it's clear what they hold so it's easier to find
211functions, classes and other stuff.
212