File: STYLE

package info (click to toggle)
glhack 1.2-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 24,604 kB
  • ctags: 18,992
  • sloc: ansic: 208,570; cpp: 13,139; yacc: 2,005; makefile: 1,161; lex: 377; sh: 321; awk: 89; sed: 11
file content (71 lines) | stat: -rw-r--r-- 1,929 bytes parent folder | download | duplicates (6)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

CONVENTIONS & DECISIONS
=======================

Filename Policy
---------------

Linux and Win32 (etc) have some different conventions for filenames,
including directory char and case sensitivity.  The rules are:

  (a) Use the platform specific convention for all internal and
      external uses.

  (b) When parsing filenames from external files, check for the
      opposite convention and do a conversion if necessary.

  (c) Choose lowercase names when there is a choice.


C++ Usage
---------

 + Use namespaces.

 + Don't use exceptions.  The code needs to be portable, and using
   exceptions makes that less likely.

 + Don't use RTTI.

 + Use signed integers for everything, rather than a mixture of signed
   and unsigned, which gets painful as you can't compare them without
   warnings from the compiler.

 + Use float directly, rather than define float_t.

 + BOOLEAN: rely on the `bool' type as standard.

 + Use `0' instead of `NULL'.

 + Memory allocation: all basic allocation done with `new' and
   `delete'.  (i.e. nothing special like Z_Malloc, Z_Free).
 

Coding style
------------

 + Indent is two space characters.

 + Comments usually _after_ the thing they comment on, for both
   class/struct members (aka. instance variables) and
   functions/methods.

 + Comments usually with //, using the /* */ style where special
   emphasis is necessary.
 
 + APIs are documented in their _header_ file (rather than body).
   Doesn't include local functions or data, of course.

 + Variable names lower case, possibly with `_' separators.  Function
   and class names usually in this style: FooBarConvert.
 
 + Variables/fields that count something have the prefix "num".

 + The header guarding constant is like this: __DIRNAME_FILENAME_H__

 + American english ("color" instead of "colour").

 + Number of minus signs in "//-------" lines : 72.
 
 + Prefer "load" over "read" (maybe "save" over "write").