Coding Style

This is how we write code in Dolphin. Because of multiple developers spread out over many many years, Dolphin is a mess of different coding standards. We stray from this ideal in many places in the code, but the mess is slowly but surely being cleaned up. Do try follow these guidelines for any new code.

The following astyle command will format very closely to our style:

astyle -A1TfpHUxdk1W1wYm0M2j filename.cpp

General Rules

 * Try to keep lines to 80 characters.
 * Prefer namespaces to classes with all members static.
 * Classes/OO is allowed, but keep it simple please. No crazy double visitor patterns etc.
 * Should you use iterators, always use pre-increment (++iter) over post-increment (iter++) where possible.
 * Use single tabs as indentation (tabs, not spaces).
 * Try to eliminate all warnings.
 * Define global variables at the top of the file/namespace they belong to.

Naming Rules

 * All class, struct and function names:
 * CamelCase
 * Compile-time constants:
 * ALL_CAPS
 * Template parameters:
 * T (capital letter)
 * All other variables:
 * lower_case_underscored
 * Variable prefixes:
 * globals
 * "g_"
 * class members
 * "m_"
 * statics
 * "s_"

Class Names

 * Use struct for POD types, class everywhere else.
 * Put class contents in public, protected, private order.
 * For each access level, put contents in constructors, destructor, operators, functions, variables order.
 * Omit unneeded sections.
 * Define static member variables first.
 * Define member functions in the order they were declared.
 * Follow the indentation/whitespace style shown in the example.

Indentation/Whitespace Style
Follow the indentation/whitespace style shown below.

DON'T DO
Do not do any of this.