Coding Style
Variable Naming and Function naming
- Starts with a lowercase letter, uses camel format for variables of several
words. Abbreviate words as much as possible, but still keeping readability.
Examples: fieldObject, mapleSyrup, varWithMoreWordsThanWeNeed.
- ...
Class Naming and Structs
- Starts with a capital letter, also uses camel format. Examples:
ObstacleAvoidance, ManicAIDeveloper, RoboSoccerTourney.
- ...
Constants
- ALL UPPERCASE. Underscores allowed. Example: THIS_IS_A_CONSTANT. Note:
iNVERTEDcAMELiSnOTaLLOWED !!!!!
File Naming
- All lowercase with underscores.
Comments
- Write comments before every function. DO NOT WRITE COMMENTS at the end of
every line so that every line is 200 characters long. Bring the comment to the
line above. Max chars per line = 72.
Tab size...
Function parameter passing
- If you need to return > 1 object/data back, pass objects to store the
output by pointer.
- If you need input and output data, pass in input(s) first by const
reference, pass in output vars to hold output by pointer.
- Note: primitive inputs can be passed in by value.
e.g. void function(const Object &o, const Pair &p, Pair
*q, Line *l)
has two inputs, an object and a pair, and two
outputs: a Pair and a Line, which are stored in parameters passed into the
function.
Issues with return types: Pair, Pair&, Pair* ...
- If you want to return a simple type, such as a Pair, for instance, of a
point found, you don't want people to modify the result because it's
pointless. Hence, return as Pair.