Sidewinder C++ coding style guide

In order to maintain consistency and readability throughout the project, contributors are requested to adhere to the following guidelines for C++ code. Where the guidelines fail to offer clarification, precedence should be sought from the surrounding code.

Indentation

  • Tabs, not spaces, should be used for block indentation.
  • Spaces, not tabs, should be used for argument alignment.

Whitespace

  • There should not be whitespace between a function name or statement keyword and its opening parenthesis.
  • There should not be whitespace between opening or closing parentheses and their contained argument list.
  • There should not be whitespace between an argument and its following comma.
  • There should be whitespace between a comma and its following argument.

Namespaces

  • Library code should always be namespaced.
  • The C and C++ standard libraries should be included using the std namespaced files (e.g. <cstdio> and <iostream> instead of <stdio.h> and <iostream.h>)

Naming

  • The names of classes should be prefixed with "C".
  • The names of class member variables should be prefixed with "m_".
  • Prudent usage of capitalisation should be employed to enhance readability when naming.

Comments

  • The necessity for comments should be absolutely minimised, using the following techniques:
    1. Sensible naming of classes, methods, variables and constants;
    2. Simplification of long algorithms or blocks of code into shorter, atomic methods.
  • C-style comments should only be used to remove blocks of code, C++-style comments should be used everywhere else.
  • The string "TODO" should appear in comments that provide details of work that is unfinished or uncommenced.
  • The string "HACK" should appear in comments that provide details of code that would either be different or entirely unnecessary if not for the presence of some bug elsewhere that is being worked around. In addition, where possible, these comments should also refer to a bug number or web page that documents the bug that is being worked around.