-
Notifications
You must be signed in to change notification settings - Fork 2
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.
- 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
- 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
- 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 than0
orNULL
- Use
static_cast<>
rather than C style casting - Use
std::unique_ptr
orstd::shared_ptr
rather thanstd::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
- We are using Doxygen
- Comments are in JavaDoc form