Documentation in code during coding
Monday, January 21st, 2008Documentation should be a pre-coding activity — documentation is a detailed design of what you are going to build, i.e. a blueprint for the program in human-readable language that describes the technical details of the program. Adding in documentation after a program is written when no specification or design exists for the program is a futile effort, since most programmers could interpret and produce the same documentation from the code itself. If a non-trivial condition discovered during maintenance is exploited in a certain block, however, that would warrant notation in the code. Suppose a repair found that a special condition that was commented out needs to be uncommented out. You’d want to note why it remains uncommented so that future programmers think twice before commenting it out again. That might look something like this:
// uncommented: X might not be less than zero when condition ABC happens in module 123
if X<0 then ...