Skip to content

Code style and structure

DunderRoffe edited this page Oct 9, 2016 · 10 revisions

Code style and structure

CMake

  • Use lower case letters on all functions.
  • Each CMakeLists.txt file should only manage files in the same directory and connections to subdirectories.

C++:

General

  • Keep all lines shorter than 100 characters.
  • Use smart pointers instead of pointers.
  • using namespace x is not allowed at any level in the code. This leas to other files and easily makes the code ambiguous.

Classes

Declaration

  • Each class should have a separate .h and .cpp file. Declaring multiple classes in the same header file is not allowed.

Constructors

For every new line, align the first parameter with the first parameter on the line above. This also applies to member definitions, with difference that the : should be placed such that the first member definition aligns with first parameter on the line above.

SomeLongClassName::SomeLongClassName(int argument1, int argument2, float argument3,
                                     float argument4, float argument5)
                                   : member1(argument1), member2(argument2)
{
    member3 = (argument3 + argument4) * argument5;
}

Functions

Operators

Python

  • Follow PEP8
  • Keep all code python3 compatible, python 2 is approaching EOL.