~ubuntu-branches/ubuntu/karmic/firebird2.1/karmic

« back to all changes in this revision

Viewing changes to doc/README.coding.style

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2008-05-26 23:59:25 UTC
  • Revision ID: james.westby@ubuntu.com-20080526235925-2pnqj6nxpppoeaer
Tags: upstream-2.1.0.17798-0.ds2
ImportĀ upstreamĀ versionĀ 2.1.0.17798-0.ds2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
  Writing FB code every coder should keep in mind these rules:
 
2
 
 
3
- Configure your editor to use 4 position for tabstop.
 
4
- indent: 1 tab
 
5
- space after e.g. if/for/while/switch - do "if (", not "if(".
 
6
- no spaces allowed between function name and leading left paren - do
 
7
"foo()", not "foo ()".
 
8
- spaces around operation - do "c = a + b;"
 
9
- spaces between function's parameters
 
10
- no spaces with pointer sign - do "*p++ = *q++" and "char *a".
 
11
- Mandatory braces around scoped code. Closing brace always aligned to the
 
12
first char of the keyword introducing the scope - i.e.
 
13
 
 
14
        if (foo) {
 
15
                // code
 
16
        }
 
17
 
 
18
or 
 
19
 
 
20
        if (foo)
 
21
        {
 
22
                //code
 
23
        }
 
24
 
 
25
first form is not allowed if condition exeeds one line. Braces may be omitted 
 
26
only if condition doesn't exceed one line and conditional statement also doesn't 
 
27
exceed one line.
 
28
 
 
29
- No spaces in C++ cast expressions. Do "static_cast<type*>(ptr)", not
 
30
"static_cast < type * > ( ptr )".
 
31
- Prefer to keep lines shorter than 80 chars.
 
32
- Prefer initialization over assignment.
 
33
- Don't break the build. Before commiting do full build cycle from
 
34
scratch (on all available platforms).
 
35
- Always end source files, including headers, with a newline.
 
36
- Prefer C++ style for comments
 
37
- Use abstract datatypes (UCHAR, SSHORT, ULONG etc) instead of generic
 
38
ones (unsigned char, short, unsigned long resp) because generic types
 
39
can be changed unexpectedly (long int become 64 bits for example).