In Extreme Programming
the rule is basically not to comment. Instead, spend the time writing the code so that it is comprehensible in itself. After all, code is an expressive language, just like a natural language. In many ways it expresses what it does much better than a comment could. Some examples were cited in a legal brief I read referring to DeCSS
that went something like,
netsalary = hourlyrate * 40 - taxvalue(hourlyrate, deductions);
- "Set net salary for one week's work by finding gross salary from hourly rate, then subtracting taxes withheld"
Ok, that wasn't the example. I just made that up. But they had that kind of examples. And the point is that if you need to comment something, in a lot of cases you should rewrite it so you don't need to comment it, instead of commenting.
Not that I totally agree with Extreme Programming. But I understand where it is coming from on this.