close Warning: Error with navigation contributor "AccountModule"

Changes between Initial Version and Version 1 of CodingStyle


Ignore:
Timestamp:
Nov 23, 2006, 10:22:36 PM (12 years ago)
Author:
hickinbottoms
Comment:

Initial version (based on old wiki)

Legend:

Unmodified
Added
Removed
Modified
  • CodingStyle

    v1 v1  
     1= Coding Style =
     2[[TracNav]]
     3
     4== Formatting ==
     5
     6The coding style should be fairly easy to pick up when looking at the source files. But here are some pointers:
     7
     8 * Indent with tabs, with 4 character tab stops.
     9
     10 * Bracing style (Use braces, even if it is a single statement):
     11{{{
     12if(condition)
     13{
     14}
     15}}}
     16
     17 * Function(), if(), switch(), etc... no space before the brackets.
     18
     19 * Code is split up into logical groups in the lib/* directories, although the use of these is minimised.
     20
     21== Naming ==
     22
     23 * Variable names are prefixed with m (class member), p (pointer), r (reference) in that order. Arguments to functions are capitalised (!ArgumentToFunction, rArgumentToFunction), local variables aren't (localVariable). Member variables are caplitalised too, but always start with m.
     24
     25 * Classes are !ClassName (with no prefix), and member functions are FunctionName(). Code lives in .cpp and .h files with the same name as the class.
     26
     27 * Non-member function calls are prefixed with ::, eg ::printf(...).
     28
     29== Language features ==
     30
     31 * #include "Box.h" must be the first include in every cpp file. On some platforms, failing to do this absolutely first will cause the compiled code to crash due to inconsistent options.
     32
     33 * Prefer references to pointers.
     34
     35 * Exceptions are used. All are autogenerated, and thrown with the THROW_EXCEPTION macro. Except for std::bad_alloc, which is thrown when memory allocations failed.
     36
     37 * Objects are allocated on the stack whereever possible to ease exception handling.
     38
     39 * No overloading of operators, especially not for i/o. Only exception is comparison operators, but even then, only if really justified. (Justification: it is not obvious what an operator will do!)
     40
     41 * Use the STL wherever useful, but don't use the STL style! (ie. the lower case names and underscores)
     42
     43 * If a function returns a newly allocated object, use an std::auto_ptr<> to return it. Do not use std::auto_ptr<> as the type for a parameter in method declarations.
     44
     45 * There is no global base class.
     46
     47 * Serialisation is done using two functions:
     48{{{
     49void ReadFromStream(IOStream &rStream, int Timeout);
     50void WriteToStream(IOStream &rStream) const;
     51}}}
     52
     53 * Serialisable objects are not derived from any particular base class as it doesn't seem necessary. Templates can be used if generic code is necessary.
     54
     55 * All serialised objects use network byte order.