Skip to content

Coding Standards

Andrew Messing edited this page May 16, 2018 · 7 revisions

With the move from Python to C++11, we have established new style guidelines for all code accepted into the master branch. This section describes our current guidelines for RIP and all RIP modules.

Syntax/Spacing Guidelines

  • Indentations should be 4 spaces - no more, no less
  • Files should not use tabs
  • Each function/method should be separated by an empty line before and after the declaration
  • Each namespace and class should be separated by two empty lines
  • Braces should be on their own line
  • There should never be more than two empty lines in a row

Naming Guidelines

  • Classes should be Pascal case
  • Functions and methods should be camel case
  • Namespaces should be lower case, only alphabetical characters
  • Constants should be Pascal case and have a 'k' prefix
  • Enum values should be camel case
  • Macros should be all upper case with underscores between words
  • File names should be lower case with underscores between words
  • Folder names should be lower case with underscores between words

C++ Feature Guidelines

  • Lambda functions only where necessary
  • Templates only where necessary
  • All enums should be scoped enums
  • Only sparingly use auto
  • Use streams where they make sense (printf is still cool though)
  • No multiple implementation inheritances
  • Interfaces and single inheritance is good and encouraged
  • Use nullptr rather than 0 or NULL
  • Use static_cast<> rather than C style casting
  • Use std::unique_ptr or std::shared_ptr rather than std::auto_ptr
  • Class variables should generally be protected or private with getter/setter methods
  • Do not use trailing return syntax (e.g. auto foo(int bar) -> int;)
  • Use structs for classes with no methods
  • Use only approved libraries from the Boost library collection. There are no approved libraries from Boost.
  • Headers should have header guards (for multiple inclusions) - all caps and underscores
  • Custom Exceptions (using the NEW_EX macro should be in the .cpp file that they are used in

Comment Guidelines

  • We are using Doxygen
  • Comments are in JavaDoc form
Clone this wiki locally