-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHACKING
53 lines (33 loc) · 1.48 KB
/
HACKING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
general:
* all classes and methods should be covered by the docs and testsuite!
* KISS [Wikipedia, KISS principle]
coding conventions:
* one class per one header file [CERN, C05]
* each header file should be self-contained [CERN, C01]
* avoid unnecessary inclusions [CERN, C02]
* protect header files from multiple inclusion [CERN, C03]
using #pragma once
* avoid multiple inheritance [CERN CB5]
* filenames should be all-lowercase
* double space indentation - no tabs (Google 'Spaces vs. Tabs')
* avoid overly long files (let's say 200 lines excluding comments) and
avoid overly long lines (let's say 100 chars)
* avoid use of preprocessor, if really needed always suffix
macro names with _macro
* both opening and closing braces on separate lines
* only Unix-style carriage returns ("\n")
* "two or more, use a for" (E.W. Dijkstra)
* declare local variables as near to their use as possible
* use references instead of pointers if possible
* mark function arguments as const where possible
References:
[Wikipedia] - KISS principle
http://en.wikipedia.org/wiki/KISS_principle
[CERN] - CERN C++ Coding Standard Specification
http://pst.web.cern.ch/PST/HandBookWorkBook/Handbook/Programming/CodingStandard/c++standard.pdf
[Google] - Google C++ Style Guide
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
[GNU] - GNU Coding Standards
http://www.gnu.org/prep/standards/
[GCC] - GCC C++ Coding Conventions
http://gcc.gnu.org/wiki/CppConventions