Somehow, among a fairly elite group of software developers, the opinion was proffered that comments are good — “the more the better.” There was disagreement, which I expected and was glad to see, but I still felt like replying:

Comments tend to rot because they don't get compiled. At best, they're accurate at the time of writing and also helpful in saving a reader's time; at worst, they're misleading later, when code has changed out from under them.

As a result, I endeavor to avoid the need for comments. Usually there are obvious ways to make code clearer: rename a function according to what it's for, extract a smaller function from within it, rename some variables to better reflect their purpose, etc. You don't have to buy the whole package deal, but it so happens there's a great deal of happy overlap between making code testable and making code comprehensible.

On rare occasions, constraints prevent such refactoring. Then, and only then — with a healthy sense of danger — I think about commenting.