tools4BCI ... Develop
hBCI Logo
Coding conventions

The main message:

and never forget:      Don't write ugly code ;-)

General rules Naming and Code structure
  • Code "language" is english
    (e.g., no "datei", "fichier", or "fichero" variable names)
  • No needless comments
    (e.g., //and this loop incements the counter)
  • No global variables
  • Comment complex code and also code-segments
    (In case of complex algorithms, describe the algorithm and don't make the code unreadable, commenting every line)
  • Use descriptive names for variables, functions, etc.
  • Avoid variable names like "x,y,z,i,..."
    (except e.g., for a loop counter, if the loop merely spans a few lines)
  • Highlight bad hacks with "//FIXXXME" and add a description
    (the number of "X" is related to the severity of the hack)
  • Add todos into the sourcecode, in case of missing features or similar
  • Add "seperators" between functions
    (e.g., 60-70 times "-" resulting in this: //-------------------- )
  • Member variables must be private
  • No silent catches
  • Exceptions must not be used for flow-control purposes
  • Documentation, documentation, documentation
    (please prefer doxygen, if possible)
  • Indent size is 2 spaces
  • Don't use 'tabs' for indents
  • Methods and Functions:
    firstWordLowercaseRestCapitalizedWithoutUnderlines
  • Constants:
    CAPITALIZED_WITH_UNDERLINES
  • Local variables:
    lowercase_with_underlines
  • Member variables:
    lowercase_with_underlines_and_a_trailing_underline_
  • Global variables:
    similar_to_members_but_ending_with_global_
  • Classes, Structs, Unions:
    AllWordsCapitalizedWithoutUnderlines
  • Exceptions:
    ClassNameEndsWithException
  • Methods, providing write access should be named: "setXYZ"
    (e.g., setUpdatecoefficient)
  • Methods, providing read access should be named "getXYZ"
    (e.g., getCoffee)
  • Boolean read methods should be named "isXYZ", "hasXYZ", "allowsXYZ,...
    (e.g., isWithCaffeine, hasEnoughCoffeeForMe,...)

Some C++ stuff:

Commit rules
  1. Do not commit code or oter files, protected by intellectual property rights
  2. Every commit must have a meaningful description (no lazy commits)
  3. Newly commited code must not make the project uncompilable
  4. For experiments and co, use branches
  5. Test commited code also on other platforms before comitting
  6. Don't add or commit unnecessary files (for git repos, have a look at .gitignore )