Mind Probe

Science Fiction, Handbells, Software Engineering, Physics

[powered by WordPress.]

18-July-2005

Documenting your code

by @ 5:54 am. Filed under Software

How much documentation should exist in today’s software source code? At one extreme, there is the architect who believed that one line of comment is too much and that code should be self documenting. This person also used Fortran style variables names (short and with all the vowels missing). I am at the other extreme. I comment my code so with the belief that if I comment it correctly, someone else can maintain it.

What do I believe is the minimum amount of documentation that should exist in the source code? At a minimum, every public method header should be well documented. This documentation should include a list describing each parameter and what is returned. In addition, the documentation should explain what the method is suppose to do, including side-effects. My school of thought is that the public methods in a C++ class (or the equivalent in other object-oriented language) should be treated like a contract. Given a set of input, the following will happen. This does not mean that the internals of the method need to be described; it means that description should inform the caller what to expect when invoking the method. The caller should not have to reverse engineer the code that implements the method.

Leave a Reply

To stop comment spam, I've added a password field for comments. The password is skyhook and should be entered into the comment password field below. This should take you no more than a couple of seconds and hopefully the spambots will not be able to deal with it.

[powered by WordPress.]

jour·nal n. A personal record of occurrences, experiences, and reflections kept on a regular basis; a diary.

Get Firefox!

internal links:

categories:

search blog:

archives:

July 2005
S M T W T F S
« Jun   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

hearing:

other:

Quotes:

"The objection to fairy stories is that they tell children there are dragons. But children have always known there are dragons. Fairy stories tell children that dragons can be killed."
    — G.K. Chesterton

"Zoology, eh? That's a big word, isn't it"
"No, actually it isn't", said Tiffany. "Patronizing is a big word. Zoology is really quite short."

    — Terry Pratchett
         from "The Wee Free Men"

general links:

I read:

bloggy links

Science Fiction

Handbells

Friends and Family

Science Fiction Authors

35 queries. 1.588 seconds