Changes between Version 21 and Version 22 of CodingStyle


Ignore:
Timestamp:
Jan 18, 2010, 3:33:39 PM (15 years ago)
Author:
Nicolas
Comment:

Explicit anchor names

Legend:

Unmodified
Added
Removed
Modified
  • CodingStyle

    v21 v22  
    33= BOINC coding style =
    44
    5 == All languages ==
    6 
    7 === Code factoring ===
     5== All languages == #all-lang
     6
     7=== Code factoring === #factoring
    88
    99 * If code is repeated, factor it out and make it into a function.
     
    1212 * C++ `.h` files often contain both interface and implementation. Clearly divide these.
    1313
    14 === Code documentation ===
     14=== Code documentation === #docs
    1515
    1616 * `.cpp` files have a comment at the top saying what's in the file (and perhaps what isn't).
     
    1818 * structs and classes are preceded by a comment saying what they are.
    1919
    20 === Naming ===
     20=== Naming === #naming
    2121
    2222 * Names should be descriptive without being verbose (local variables names may be short).
     
    2525 * No mixed case names.
    2626
    27 === Indentation ===
     27=== Indentation === #indent
    2828
    2929 * Each level of indentation is 4 spaces (not a tab).
     
    4747}}}
    4848
    49 === Constants ===
     49=== Constants === #constants
    5050
    5151 * There should be few numeric constants in code. Generally they should be `#define`s.
    5252
    53 === Braces ===
     53=== Braces === #braces
    5454
    5555 * Opening curly brace goes at end of line (not next line):
     
    7474
    7575
    76 === Comments and #ifdefs ===
     76=== Comments and #ifdefs === #comments
    7777
    7878 * Use `///` for all comments. The documentation is generated using Doxygen, so you should have a look at this example:
     
    132132}}}
    133133
    134 == C++ specific ==
    135 
    136 === Includes ===
     134== C++ specific == #cpp
     135
     136=== Includes === #includes
    137137
    138138 * A `.cpp` file should have the minimum set of #includes to get that particular file to compile (e.g. the includes needed by {{{foo.cpp}}} should be in {{{foo.cpp}}}, not {{{foo.h}}}).
    139139 * Includes should be ordered from general (`<stdio.h>`) to specific (`thisfile.h`).
    140140
    141 === Extern declarations ===
     141=== Extern declarations === #extern
    142142
    143143 * {{{foo.h}}} should have '{{{extern}}}' declarations for all public functions and variables in {{{foo.cpp}}} There should be no '{{{extern}}}' statements in {{{.cpp}}} files.
    144144
    145 === Use of static ===
     145=== Use of static === #static
    146146
    147147 * If a function or variable is used in only one file, declare it {{{static}}}.
    148148
    149 === Things to avoid unless there's a truly compelling reason: ===
     149=== Things to avoid unless there's a truly compelling reason: === #try-avoid
    150150
    151151 * Operator or function overloading.
    152152 * Templates.
    153153
    154 === Things to avoid ===
     154=== Things to avoid === #avoid
    155155
    156156 * Use `typedef` (not `#define`) to define types.
    157157 * Don't use `memset()` or `memcpy()` to initialize or copy classes that are non-C compatible. Write a default constructor and a copy constructor instead.
    158158
    159 === Error codes ===
     159=== Error codes === #error-codes
    160160
    161161 * (Almost) all functions should return an integer error code. Nonzero means error. See [source:trunk/boinc/lib/error_numbers.h lib/error_numbers.h] for a list of error codes.
     
    166166}}}
    167167
    168 === Structure definitions ===
     168=== Structure definitions === #structs
    169169
    170170{{{
     
    178178}}}
    179179
    180 == PHP specific ==
    181 
    182 === HTML ===
     180== PHP specific == #php
     181
     182=== HTML === #html
    183183
    184184PHP scripts should output "HTML 4.01 Transitional".
     
    226226
    227227
    228 === Getting POST and GET data ===
     228=== Getting POST and GET data === #post-and-get
    229229
    230230Do not access `$_POST` or `$_GET` directly.
     
    232232These undo the effects of PHP magic quotes.
    233233
    234 === Database access ===
     234=== Database access === #database-access
    235235 * Use the [PhpDb database abstraction layer].
    236236 * If a POST or GET value will be used in a database query, use `BoincDb::escape_string` to escape it.