Coding guidelines

This is a list of guidelines that you should check your code against before submitting each assignment.
  1. Use meaningful variable names, but try to keep them short.
  2. Never use a variable for two difference purposes.
  3. Avoid duplicate code. Either condense it somehow or write a function.
  4. Keep variables in as local scope as possible.
  5. Make variables const when possible.
  6. Use comment blocks rather than commenting every line.
  7. Avoid comments that state the obvious.
  8. Make comments meaningful.
  9. Always enclose the body of control structures (e.g. if, for, etc) in braces even if there is only one line in the body.
  10. Prefer for loops to while loops. Always use a for loop when the iteration variable will be incremented the same each iteration.
  11. Prefer passing non-primitive data types as const reference parameters.
  12. Keep class data members private.
  13. Never return a non-const reference to a class data member.
  14. Use val[i] rather than *(val+i) when using arrays.
  15. Use val->a() rather than (*val).a() when using pointers.