Debian Codegraph @

HACKING

raw
1 Coding Style
2 ============
3
4 Formatting
5 ----------
6
7 - No tabs.
8 - Indent is 4 spaces.
9 - A line should be 80 chars in length, with a maximum length of 90 chars
10 - Brackets are always on separate lines.
11 - Put spaces between brackets of if, while and
12 similar statements.
13 - Follow the style of the rest of the file if it is different from these
14 guidelines
15
16 Example:
17
18 void MyClass::myFunction(const QString& arg)
19 {
20 if ( blah == "halb" )
21 {
22 doSometing();
23 }
24 else
25 {
26 varA = varB;
27 }
28 }
29
30
31
32 Header Formatting
33 -----------------
34
35 - Access modifiers are not indented.
36 - Double inclusion guard defines are all upper case
37 letters and are composed of the namespace (if available),
38 the classname and a H suffix separated by underscores.
39 - Inside a namespace there is no indentation.
40
41
42 Example:
43
44 #ifndef NAMESPACE_MYCLASS_H
45 #define NAMESPACE_MYCLASS_H
46
47 namespace Namespace
48 {
49
50 class MyClass
51 {
52 public:
53 MyClass();
54
55 private:
56 int m_intVar;
57 QProcess* m_proc;
58 };
59
60 }
61
62 #endif
63
64
65
66 Class and File Names
67 --------------------
68
69 - Use .h and .cpp for the header and source files, respectively
70 - Do not abbreviate words in filenames
71 - Use the classname without the namespace as the name of the file
72
73 Example:
74
75 class FooDialog : public QDialog
76 {
77 public:
78 FooDialog( QWidget* parent );
79 };
80
81 has files foodialog.h and foodialog.cpp instead of foodialog.h and foodlg.cpp
82
83
84 Class and Variable Names
85 ------------------------
86
87 - For class, variable and function names separate multiple
88 words by uppercasing the words preceded by other words.
89 - Class names start with an uppercase letter.
90 - Function names start with a lowercase letter.
91 - Variable names start with a lowercase letter.
92 - Member Variables of a class start with a 'm_' prefix
93 followed by an lowercase letter.
94 - Use descriptive names where possible. Write "job" instead of "j", for
95 example.
96
97 Member Functions
98 ----------------
99
100 - Do not write inline accessors. All code should be in the .cpp files
101