This is a short list of coding standards that your programs
should generally adhere to.
- Each Source File should have a comment block at the top, with your name, the date, the program filename, and a short description in it.
- Variables names should be self describing, exceptions being loop counters in for loops, etc.
int myWeightInPounds; int timeoutInMsec;
- Function names should also be self describing
CheckForErrors() instead of ErrorCheck(), DumpDataToFile() instead of DataFile().
- Use consistent case. camelCaseIsFine
- Indentation - always exactly 3 spaces, not tabs.
- No magic numbers - any number other than 0 or 1 should have a constant defined for it.
Example:
const int squareFeetInSquareYard = 9;
- Use spaces in all assignment statements, and always use brackets in control / repetition statements
for ( int i = 0; i < someConstant; i++ )
{
//do something
}
if ( a == b )
{
//do something
}
- Use meaningful comments to describe complex situations, avoid unless comments.