CSCI 1321 (Principles of Algorithm Design II), Spring 2001:
Tips for Writing Clear and Well-Documented Code

Overview

Something that early programmers did not fully appreciate is that programs tend to take on a life of their own, being reused and modified over a period of years, often by people other than their original authors. The better a job the original author did of documenting the program and writing it clearly, the easier it will be to reuse and modify.

Documentation

By ``documentation'' I mean comments at the start of the program that help potential users understand exactly what the program does without necessarily understanding how and definitely without reading the whole program. Generally speaking, these comments should describe the program's inputs (command-line arguments, file input, input from standard input) and outputs (file output, output to standard output) and how they are related.

Clear code

The object of these suggestions is to make the code clear and readable for the human reader, perhaps a programmer who wants to reuse it with modifications. Here are some tips for writing clear code.



Berna Massingill
2001-01-29