I’m working as a tester on a project for a small finance company. While management sometimes makes “interesting” decisions, the team I’m working with seems competent enough. Since I’m usually on the developer part of the equation (this project being a temporary job) I’ve taken an interest in the code of the project. Today I remarked that the code seemed to be pretty light on comments (which isn’t an exaggeration; there aren’t any) and was immediately told that it’s intentional and that “source code comments are your worst enemy in large code bases.”
Being hired as a lowly tester and not having any real experience developing large, enterprisey systems, I didn’t see fit to question this sentiment but I’m still wondering if this really is a universally accepted fact?
Of course code should be written in a clear, self-explanatory manner as far as possible, reducing or eliminating the need to comment individual code snippets, but this project intentionally doesn’t seem to use any comments at all, not even xmldoc comments for methods and/or classes, which just seems horribly wrong to me. Is this really universally agreed on as best practices for large projects?
Comments do tend to get out of date, and an incorrect comment is indeed worse than no comment. Likewise, xml comments if enforced by mandate tend to be so minimal (just to make the compiler happy) as to add zero value.
However; comment when comment is due is fine IMO. I am very light on my comments, but when I add a comment it is important – it might explain the reason for a particular design choice; some non-obvious facet of the logic that needs to be understood; or some gnarly threading concerns that the casual reader must be aware of. It might cross-reference a business rule, an error-ticket/case-number, or cite some external reference for more information on a topic.
So indeed, I agree with you that no comments (by rule) is stupid. But too many comments is stupid too (IMO). I want my focus brought to stuff that matters, and I can’t do that if the code is drowning in green.