This is the start of the SIGCSE thread that resulted in this article.
Angersock’s Law of Comments
Comment every change in level of abstraction or encapsulation, and any algorithm that has subtlety–otherwise, just don’t use opaque identifier names and you’ll be fine.
most of my comments tend to be either of the “why is this code here at all?” variety (which is a separate issue from algorithmic subtlety or bad variable names), or as section headers for a long function or file that for various reasons would be worse off if broken up.
Special exemption for regex?! ;-)
Falls under “subtlety”.
Replace the urge to comment with refactoring to improve your position in the Rusty scale… http://sweng.the-davies.net/Home/rustys-api-design-manifesto
Alternatively add an assert, think of an assert as an executable comment and at least bumps you to level 5 on the scale.
Sure, if you own the API, but I comment to talk about the nasty inner workings of other APIs, because usually my API exists so you don’t have to do the dancing and ceremony of the other API yourself. If it were easy and hassle free, I’d let end users do it themselves or just not comment.