Style - Tsukumokun/arc GitHub Wiki

All files in the ARC project should follow this style guide

Tabs

  • 4 spaces - never tabs

Empty lines

  • 2 between functions
  • 1 at the end of the file

Comments

  • Only where useful for deciphering code, code should be clean enough in most cases to speak for itself
  • Functions in cxx files should be prefixed with
  • //---------- [Namespace::][Class::][function()] ----... (should always be 80 characters)
  • All hxx documentation should follow rules set forth by doxygen with the exception of strong comments. If you need a strong comment, you are probably documenting incorrectly (see doxygen.org)

Character limit

  • Make every attempt to not go beyond 80 characters.

Parentheses

  • Following a function, no space separating
  • Following a keyword (if,while,for, etc) one space
  • delete, new, return, etc should not have parentheses
  • Nested parentheses should increase space separation with each nest.
  • Example: int a = ( ( (2 + 3) - 4 ) * 2 );
  • Example: int a = func1( func2( func3() ) );
  • If you need to nest beyond 2 levels, rethink your code.

Parameters

  • Separated by a space
  • Example: int func1(int a, int b, int c)

Brackets

  • Opening and closing curly brackets should appear on lines by themselves
  • All if/else clauses must have brackets, even if there is one line (for flow readability)

Alignment

  • Where possible align variables and parameters to make the code readable and neat