source: pacpusframework/branches/0.0.x/CODING_STYLE.txt@ 185

Last change on this file since 185 was 64, checked in by Marek Kurdej, 12 years ago

Modified property: added svn:keywords=Id.

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1For the aspects not explained in this document, follow the coding style described in:
2 http://llvm.org/docs/CodingStandards.html
3
4== #include Style ==
5* Avoid #includes in the header files. Use forward declarations if possible.
6* Immediately after the header file comment (and include guards if working on a header file), the minimal list of #includes required by the file should be listed. We prefer these #includes to be listed in this order:
7 1) Main Module Header
8 2) Local/Private Headers
9 3) <Pacpus/...>
10 4) System #includes
11* do not use 'using ...;' in header files
12
13== Mechanical Source Issues ==
14* use standard header-guard:
15 #ifndef PACPUS_EXAMPLE_H
16 #define PACPUS_EXAMPLE_H
17 ...
18 #endif // PACPUS_EXAMPLE_H
19* use C++-style comments (//)
20* ALWAYS use curly brackets with statements if, for, etc.
21* use curly brackets {} as follows:
22 * on the same line with:
23 - namespace {
24 - statements if, for, etc.
25 if (cond) {
26 } else if (cond2) {
27 } else {
28 }
29 * on the next line with:
30 - classes
31 - function and method definitions
32 - local scope blocks
33 class A
34 {
35 void fun A;
36
37 struct AB
38 {
39 };
40
41 void fun A
42 {
43 }
44 };
45* write Doxygen-style comments as much as possible, put it in the header file if possible, add developer-only comments in source file
46* use Java-style Doxygen comments, i.e. @returns over \returns
47* use preprocessor directives for long-range comments (#if 0 .... #endif)
48* indent with 4 spaces, do not use tabs
49* do not indent namespaces
50* use camelCaseNotation / CamelCaseNotation
51* end namespace with its name in a comment
52* start with a lowercase letter for local variables, namespaces, function names, method names, ...
53* start with an Uppercase for classes, structs, ...
54* prefix member variables with 'm'
55* prefix (static) const variables with 'k'
56* prefix static (non-const) variables with 's'
57* separate member methods from member variables with a repetion of 'protected:' / 'private:'
58
59========================================
60Example.h:
61========================================
62/// File description
63
64#ifndef PACPUS_EXAMPLE_H
65#define PACPUS_EXAMPLE_H
66
67#include "BaseClass.h"
68
69namespace pacpus {
70/// Constant description
71static const double kConstA;
72/// Static variable description
73static int sStaticA;
74
75/// Brief description of this class
76///
77/// Somewhat longer description of this class
78class SomeClass
79 : public BaseClass
80{
81public:
82 SomeClass
83
84private:
85 void methodA();
86
87private:
88 int mMemberA;
89};
90
91} // namespace pacpus
92
93#endif // PACPUS_EXAMPLE_H
94
95========================================
96Example.cpp:
97========================================
98#include "Example.h"
99
100#include "Something.h"
101#include "SomethingElse.h"
102
103#include <Pacpus/kernel/DbiteFile.h>
104
105#include <iostream>
106
107using namespace pacpus;
108
109const double kConstA = 3.14159265;
110
111SomeClass::SomeClass()
112 : BaseClass()
113{
114 int someIntegerVariable;
115
116 if (a) {
117 a();
118 } else {
119 b();
120 }
121
122 if (isConditionSatisfied()) {
123 doSomething();
124 return 0;
125 }
126 return 1;
127}
Note: See TracBrowser for help on using the repository browser.