summaryrefslogtreecommitdiff
path: root/doc/CODESTYLE
diff options
context:
space:
mode:
authormathias <mathias>2006-04-22 07:03:58 (GMT)
committermathias <mathias>2006-04-22 07:03:58 (GMT)
commitdc532830606461182f5b9fbac54847a1b3c5b080 (patch)
tree19067747564dca5d1bdabd00c1e0024735187d73 /doc/CODESTYLE
parentedafa987bee64b898ab301263431f97fbd9445e2 (diff)
downloadfluxbox_lack-dc532830606461182f5b9fbac54847a1b3c5b080.zip
fluxbox_lack-dc532830606461182f5b9fbac54847a1b3c5b080.tar.bz2
* cosmetics to Workspace.hh CurrentWindowCmd.cc
* added first draft of new docs in asciidoc format, needs to be converted properly to roff-format, right now its just a temporary "home" * rename of Coding_style to CODESTYLE
Diffstat (limited to 'doc/CODESTYLE')
-rw-r--r--doc/CODESTYLE214
1 files changed, 214 insertions, 0 deletions
diff --git a/doc/CODESTYLE b/doc/CODESTYLE
new file mode 100644
index 0000000..47bd173
--- /dev/null
+++ b/doc/CODESTYLE
@@ -0,0 +1,214 @@
1Use 4 space indent
2Spaces between ","
3ex: 1, 2, a, 4
4
5if/else-statements:
6An else clause is joined to any preceding close curly brace
7that is part of its if.
8
9if (....) {
10 ....
11} else {
12 ....
13}
14if the line needs to be splited up, right after an if-statement
15use { and }, so its clear when the if-statement ends.
16ex:
17if (...) {
18 function(.....,
19 ......, .... );
20}
21
22This is ok:
23if (...)
24 shortline(...);
25
26
27while-statement:
28
29while (...) {
30 ....
31}
32
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
76Include guards:
77For files with namespace:
78#ifndef NAMESPACE_FILENAME_HH
79#define NAMESPACE_FILENAME_HH
80....
81
82#endif //NAMESPACE_FILENAME_HH
83<eof>
84
85Without namespace:
86#ifndef FILENAME_HH
87#define FILENAME_HH
88....
89
90#endif //FILENAME_HH
91
92<eof>
93
94preprocessors:
95The # of all preprocessor commands must always be in column 1, and never use
96indentation for preprocessor directives
97
98They should always have a // PREPROCESSOR to mark where they end
99#ifdef DEBUG
100...
101...
102#endif //DEBUG
103
104Don't use preprocessors for constants or macro-functions, they can be
105cryptic and sometime make it hard to debug.
106
107
108functions:
109The name starts with a lowercase and then a uppercase for name separation:
110void functionWithAName(...) {
111 ...;
112}
113
114Use Javadoc style for function description (see www.doxygen.org)
115Function comments:
116/**
117 This do that and that
118 @return this on success else this on failure.
119 TODO: if there is something to do.
120*/
121void functionDoes(...) {
122
123}
124
125Class:
126Order: public, protected and then private
127Class names always starts with a big letter.
128Class data members are prefixed by m_ , static data members are prefixed with s_ .
129Class member function will be organized according to creator,
130manipulator and accessors categories.
131
132class Classname:public AnotherClass {
133public:
134 //1. public enums, structs
135
136 //2. constructors and destructor
137
138 //3. manipulators
139
140 //4. accessors
141
142protected:
143 //1. enums, structs
144
145 //2. functions
146
147 //3. variables
148
149private:
150 //1. enums, structs
151
152 //2. functions
153
154 //3. variables
155};
156
157
158struct follows the class style.
159
160namespace:
161namespace TheName {
162...;
163...;
164}; //end namespace TheName
165
166Don't use "using namespace thenamespace;" in header-file
167We don't want to force the other files, that include the file, a namespace.
168
169
170try/catch-statement:
171
172try {
173 ....;
174} catch (...) {
175 ....;
176}
177
178Variables:
179Avoid variables that contain mixtures of the numbers 0 & l and the letters O
180and 1, because they are hard to tell apart.
181Having a type name and a variable differing in only in case (such as:
182 String string;) is permitted, but discouraged.
183
184Use lowercase for variables and use _ to separate names, ex:
185int number_of_screens;
186int num_colors;
187
188
189All constants must be in Upper case letters.
190
191enums must be in uppercase letters and not in file scope:
192enum {WHITE, RED, BLUE};
193
194Other:
195
196if (strcmp(...) == 0) //good
197if (!strcmp()) //bad
198
199Don't create free-functions, encapsulate them in a namespace or a class
200and name filenames so it's clear what they hold so it's easier to find
201functions, classes and other stuff.
202
203
204ChangeLog format:
205*year/month/day:
206 * whats changed (who changed it)
207 which file
208
209ex:
210
211*02/01/01:
212 * Fixed bug workspace change (TheDude)
213 Workspace.cc
214