This website is preserved for historical and scholarly reference and is no longer actively maintained.
Style Standards for Assignments (#3, #4)
The purpose of style standards is to make programs more readable by humans.
- Your name must be printed as a comment on every file turned in
- Use either 3 or 4 spaces for each indentation. Be consistent. Pick a number and stay with it. Do not use tabs to indent because the printer does not have the same tab spacing as the computer. Use the space bar to indent.
- Every method (function) you write must have a clearly stated postcondition.
- If there is any condition required to execute the method (function), it must be clearly stated as a precondition.
- Every method (function) must begin with a section of comments giving a clear English statement of the algorithm. The algorithm may be omitted only if the method (function) contains fewer than 10 lines of code and the code is self-documenting.
- Every C++ statement must begin on a separate line.
- If the condition for execution, such as in a while or if statement can be written in the form "( constant == var )" it may not be written in the form "( var == constant )".
- Always use #ifndef for .h files.
- Comments must be included when they will aid the reader in understanding the program. Do not comment the obvious. Do comment the "what" you are doing, but rarely the "how".
- Use meaningful variable names. Do not use the single letter 'o' or the single letter 'l' for variable names.
- Use white space to set off logical ideas.
- If you use code, text, ideas, etc. that are not your own (from text, web, etc.) cite the source.