1 ================================================================================
3 ================================================================================
5 We use 4 spaces instead of tabs everywhere.
9 if(bar()) // <-- 4 spaces
13 ================================================================================
15 ================================================================================
17 Opening braces should always be on their own line.
41 Exceptions include inline functions that are just returning or setting a
42 value. However multiple statements should not ever be combined onto one line:
47 String value() const { return m_value; }
50 Same goes for the main namespace of a header (the namespace where the class
51 declaration is in, opposed to forward declaration (see also "Namespaces")
53 ================================================================================
55 ================================================================================
57 Spaces should be used between the conditional / loop type and the
58 conditional statement. They should not be used after parenthesis. However
59 the should be to mark of mathematical or comparative operators.
64 The marked spaces should be ommitted to produce:
68 ================================================================================
70 ================================================================================
74 For test.h, declaring the class Akregator::Test, use AKREGATOR_TEST_H, not TEST_H,
75 nor _AKREGATOR_TEST_H_ etc. Comment the closing #endif.
77 #ifndef AKREGATOR_TEST_H
78 #define AKREGATOR_TEST_H
80 #endif // AKREGATOR_TEST_H
82 Member variables should always be private or protected and prefixed with "m_".
83 Accessors may be inline in the headers. The organization of the members in a
84 class should be roughly as follows:
100 If there are no private slots there is no need for two private sections, however
101 private functions and private variables should be clearly separated.
103 The implementations files -- .cpp files -- should follow (when possible) the
104 same order of function declarations as the header files.
106 Virtual functions should always be marked as such even in derived classes where
107 it is not strictly necessary.
109 ================================================================================
111 ================================================================================
113 - Do not indent stuff in the "main namespace" of a file. But do for forward declarations.
114 - comment the closing bracket of the namespace with // namespace Foo
122 namespace Akregator {
128 } // namespace Akregator
130 ================================================================================
132 ================================================================================
134 Whitespace should be used liberally. When blocks of code are logically distinct
135 I tend to put a blank line between them. This is difficult to explain
136 systematically but after looking a bit at the current code organization this
137 ideally will be somewhat clear.
139 Also I tend to separate comments by blank lines on both sides.
141 ================================================================================
142 Pointer and Reference Operators
143 ================================================================================
145 Use "Foo* f" and "Foo& f" in function signatures and declarations. And also in
148 ================================================================================
150 ================================================================================
152 Prefix slots/signals with "slot"/"signal". Fully qualify types used in arguments
153 (i.e. add namespaces).
161 signalFoo(const Akregator::Article&);
169 ================================================================================
170 Pointer and Reference Operators
171 ================================================================================
173 An example object here:
176 #ifndef AKREGATOR_TEST_H
177 #define AKREGATOR_TEST_H
179 #include "localinclude.h"
180 #include "anotherlocalinclude.h"
181 #include <kdeinclude1.h>
182 #include <kdeinclude2.h>
183 #include <qtinclude1.h>
184 #include <qtinclude2.h>
188 namespace Akregator {
190 class Test : public QObject
195 typedef QValueList<Test> list;
198 Test(QString someString);
199 explicit Test(int i = 0);
204 void someFunc2(QSomething *foo);
206 static Test *instance() { return m_instance; }
209 void receive(QSomething &);
212 void send(QSomething &);
215 void someProtectedFunc();
217 static void someProtectedStaticFunc();
220 void protectedSlot();
228 static int staticPrivateMethod();
231 void privateSlotIndeed(int youWonder);
235 QSomething* m_tastyThing;
237 static Test* m_instance;
240 } // no ; after namespace (borks on gcc 3.4+)
246 #include "localinclude.h"
247 #include "anotherlocalinclude.h"
248 #include <kdeinclude1.h>
249 #include <kdeinclude2.h>
250 #include <qtinclude1.h>
251 #include <qtinclude2.h>
252 #include <qsomething.h>
254 namespace Akregator {
265 Test::Test(QString someString)
269 , m_tastyThing(someString)
282 kDebug() << "Zero initializer";
285 } // namespace Akregator
287 ================================================================================
290 Scott Wheeler <wheeler@kde.org>
292 Amendments for Akregator needs by
293 Stanislav Karchebny <stanislav.karchebny@kdemail.net>
294 Frank Osterfeld <osterfeld@kde.org>