Skip to content

Coding Style Guidelines

Darren Shen edited this page Nov 22, 2015 · 2 revisions

This document contains some guidelines to contributing code to Stateline. By default, follow this guideline. For anything not covered in this guideline, refer to the C++ Core Guidelines.

Language

  • Does it really need to be a class/have internal state?
  • Do you really need inheritance in this circumstance? (probably not, unless you've got a container of the parent type full of different child types).
  • Use #pragma once for header guards.

Whitespace

  • Braces on a newline.
  • 2 space indent.

Documentation

  • Use Doxygen for documenting functions and classes.
  • Use // style comments.
  • Document files, classes, functions and methods using Doxygen C++ style.
  • Add the copyright licence header to every source and header file.
  • Comment with proper capitalisation and punctuation.

Naming

  • camelCase for variables and functions with lower case beginning
  • PascalCase for classes.
  • SCREAMING_CAPS_FOR_CONSTANTS
  • underscore_ notation for private member variables.
  • .hpp for headers, .cpp for source files
  • Australian english spelling of all variables (e.g. marginalise not marginalize).

IO

  • Use logging over iostream
  • Use iostream over stdio
Clone this wiki locally