Skip to content

guidelines

tcpan edited this page Jan 13, 2014 · 17 revisions

C++ Programming Guidelines

We base our style and best practice guidelines on the ones at geosoft.no with a few modifications.

Style guideline modifications:

  • 11. Don't use the underscore _ suffix for private members.

  • 24. We use the Id suffix instead of the No suffix.

  • 34. We use the file extensions .cpp and .hpp.

  • 36. In some cases it might be permitted to define methods in the header files (e.g. when templating)

  • 58. break and continue are permitted.

  • 70. Use nullptr for Null-Pointers instead of 0 or NULL

  • 72. Use form 2 only. // DO: if ( ) { // do something } else { // do something else }

  • 83. Don't put the function return type on a separate line.

  • 85. Don't put a space between the function name and the first (. DO: foo(bar), NOT: foo (bar).

  • 90. - 94. We use Doxygen style comments.

  • colon between class name and superclass list is surrounded by space. Elsewhere colon is suffixed with a space (label, switch cases) class A : B, C

  • throw declaration has the form throw (...)

  • constructor initializer list's colon should go on the next line if wrapping.

Practice guideline modifications:

  • 10. If no copy constructor and/or assignment operator is defined, disallow those operations by declaring but not defining a private copy constructor and assignment operator. This can be done with Google's DISALLOW_COPY_AND_ASSIGN macro.
  • 16. The == and != operators don't always need to be implemented .

Additional best practice policies/guidelines

Additionally to the practice guidelines from geosoft.no we use part of the Google C++ Style Guide:

  • See our [Additional practice guidelines](google style guide)

Editor Configurations

Eclipse

  • TO BE POSTED