Pop Quiz: Why Don't Good Developers Want to Write Comments?
Before going to consider whether comments are really needed, let’s consider few other things that already became “rivals” of it.
- Unit Tests: Having well written unit tests are smarter and useful solution, than detailed comments. Unit tests not only can check for the quality (and better architectural design in case of TDD), but also serves as a documentation regarding how the API should be used.
- Advanced IDE Features: With the advanced features, such as conditional debugging, call stack, dependency graph (and a lot more) in modern IDE’s its relatively easy to understand the code without manually reading the comment and the code.
- Architectural Documentation: A well written architectural documentation really helps people who intend to start working on an existing codebase.
Now the first question, whether comments are needed? The short answer is, yes. However in real world comment may lead to confusions if they are not maintained through the change cycle of the code. Thus it should be written only when it is really needed and should be maintained.
And the next question is why good developers don’t want to write comment? I’d say, people who build software that meet quality, time and budget accordingly are good developers, where almost everyone uses the “rivals” of comments, along with bare minimum comments (that are truly required), some of them are more obsessed to focus on unit tests, as these are automated and easy to maintain than comments.