When handing in software code observe the following guidelines:
- Strictly follow an indent style, such as described in the Wikipedia entry: https://en.wikipedia.org/wiki/Indent_style. You may use either the “K&R” or “Allman” styles. I prefer the Allman style, with 4 spaces per indent. You may want to ensure proper formatting by using a tool for “prettyprinting”, such as Polystyle (free trial at http://www.polystyle.com/download/)
- Fully comment your code — any non-obvious steps must be commented.
- Use descriptive variable names — do not be afraid of long variable names. Your primary goal is to produce bug-free code that someone else can easily read and understand.
- Adhere to a single variable/type/procedure naming convention. You can use underscores or camel-case (I prefer all lower case, and underscores). DO NOT MIX conventions!
- void my_function ( int this_is_a_variable )
- void MyFunction ( int ThisIsAVariable )
- Use “spaces” rather than “tabs”. This ensures that the text format appears the exact same for everyone, regardless of editor/viewer settings.
- Do not insert special numbers in your code. For example instead of:
-
velocity = velocity + 32; // do the following instead
-
#define GRAV_ACCEL (32)
-
velocity = velocity + GRAV_ACCEL;
-
- ORGANIZE YOUR CODE into subroutines and separate files, as appropriate!