Skip to content

Coding Style

Russell Blickhan edited this page Jun 9, 2018 · 8 revisions

The following is coding style decisions we have made:

  • Use enum struct for all enums.
  • Use struct to bundle things without functions/methods (with the possible exception of a constructor/destructor), use class for everything else (i.e. with methods).
  • Use m_ prefix for member/instance variable names and p_ prefix for pointer names (m_ takes precedence over p_, in the case of member pointers).
  • Use C++-style casts (e.g. static_cast, dynamic_cast) instead of C-style casts, except when casting only primitives, in which case C-style casts are allowed.
  • Use nullptr instead of NULL.

#include Order Structure:

  • Directly related header file first
  • Empty Line
  • Project header files alphabetically
  • Empty Line
  • Standard header files alphabetically

#include Order Structure Example (VM.cpp):

#include <VM.h>

#include <debug.h>
#include <DurianObject.h>
#include <opcode.h>

#include <cstdlib>
#include <iostream>
Clone this wiki locally