Tekkotsu coding standards

From Tekkotsu Wiki

Revision as of 20:50, 26 January 2016 by Touretzky (Talk | contribs)
Jump to: navigation, search

This page documents the current standards for Tekkotsu code. Older modules may not adhere entirely to these standards, but as files are revised they will gradually come into compliance. Tekkotsu mostly follows the Google C++ style.

Contents

Identifiers

  • Use medial capitals (camelCaseIdentifiers) rather than underscore_separated_identifiers.
  • Class names begin with a capital letter.
  • Method and instance names begin with a lowercase letter.
  • Enumerated type names end in _t, e.g., EventBase::EventTypeID_t.

Punctuation

  • Always put a space between a keyword and a delimeter, e.g., between if and the left parenthesis.
  • Always put a space between a right parenthesis and a left brace.
  • It's usually a good idea to put spaces around major operators, e.g., x = 3 rather than x=3.
  • Don't put a left brace on a line by itself; put it on the same line as the if or for statement.

Tabs vs. Spaces

  • Use spaces for indentation. Don't use tabs because editors don't agree on how much to indent for a tab. (This is a recent change to the Tekkotsu standard, so most source files are not yet in compliance.)

Constants

  • Avoid using #define. Instead, declare static constants so that they are properly contained in a namespace.