Chapter 5: A PASSING COMMENT How to Write Code Comments
- Learn to write enough comments, and no more. Favor quality, not quantity.
- Spend your time writing code that doesn’t need to be propped up by tons of comments.
- Bad comments are worse than no comments at all
- Good comments explain why not how.
- Don’t duplicate code in a comment.
- When you find yourself writing dense comments to explain your code, step back. Is there a bigger problem to solve?
- Think about what you’re writing in a comment; don’t type without using your brain. Read it back again in the context of the code. Does it contain the right information?
Jun 20, 2010
comments powered by Disqus