next up previous
Next: Ease of use Up: Coding Style for CS2005 Previous: Source Code Formatting and

Documentation

As suggested in the textbook, a homework requirement (necessary for full credit) is to provide pre- and post-condition descriptions for each function or method except main. The precondition description must suffice for a programmer who has no access to the function's source code to determine which input is expected and under which conditions the function will work as described. Likewise, the postcondition description must show clearly what a function does and what the returned data means. Always assume that someone else uses one of your functions and has no access to your source code.2 Also, the purpose of global variables must be explained in a comment. Furthermore, any function implementation that is not trivial should be commented (any non-obvious algorithm or program statement deserves an explanation). If you would look at your code again in six months, you should be able to understand the program logic without difficulties.

Andreas Koeller
2000-06-04