
I've used, or been forced to use, many different commenting conventions over the years. The most awkward was a coding standard that required big banners at the top of each source file and a header comment for each function that repeated the information that was in the function's signature and followed it with a description of the function's behaviour that usually ended up pointlessly rephrasing the function's name. Another awkward commenting convention I've had to use is Javadoc : source code can become quite unreadable when it contains long comments that contain HTML markup.
A common misconception of agile software methods is that they eschew comments completely. On the contrary, like everything, it's a matter of context and sometimes comments are necessary. Agile methods try to use meaningful identifiers as much as possible to reduce comment noise and to ensure that human readable text is always kept up to date. In my projects, I have come to use a commenting practice that can be summed up by a pithy one-liner that Joe suggested I post here:
Identifiers say what. Comments say why.
Code is usually straightforward enough to require no more commentary than the identifiers provide. However, when I have to make an unusual design decision, I add a comment explaining why I have done what I have done.
You might like dydoc then:
http://alt.textdrive.com/dydoc/
Posted by: PA at January 14, 2005 5:11 PMSpare a thought for us poor souls in the component world who have to write copious amounts of Javadoc API documentation in our source code. There really doesn't seem to be a way round it as users need lots of context specific help on public methods and the like.
Not that I'm complaining about documentation - that is absolutely required. But it is a pain writing HTML inside .java files.
Posted by: Richard Rodger at January 14, 2005 5:28 PMThanks PA, I'll take a look. A documentation tool I like a lot, and that has had a big influence on the way I write tests, is TestDox (http://agiledox.sourceforge.net/).