Charles Miller posts a missive regarding the value of commenting performance hacks.
Included is a perfect example of a reasonable comment. It leads me to a very simple guideline:
Comments should contain meta-information about the code in question.
Things that make sense to comment are your state of mind when writing something, other approaches you tried, location it was borrowed from, protocol reference material, etc...Stuff that helps describe the code itself, and why it is what it is.
Most other sorts of comments should be looked at as warning signs. I'm not saying that all other comments should be removed; but if you have comments that indicate calling order dependencies, you owe it to yourself to try and figure out a way to express the API in a way that makes those dependencies implicit (or removes them altogether).
This is Rob Meyer's weblog, a weblog focused on software development and system administration based on 10 years of experience. Want to explore further? You can find out more me or see the rest of my website.
Wondering if I've written on something in particular? Try searching:
You might want to take a look at some of the more requested postings (as judged by incoming traffic):
Want more? Subscribe to this site
or contact me at rob at big dis dot com.
See my writings on: