Comments are important because they help programmers make sense of code. A bad comment is worse than no comment at all, but it's hard to measure the quality of comments. Comments should not duplicate the code and should not excuse unclear code. Comments that add no information have negative value because they add visual clutter.

8m read timeFrom stackoverflow.blog
Post cover image
Table of contents
Rule 1: Comments should not duplicate the codeRule 2: Good comments do not excuse unclear codeRule 3: If you can’t write a clear comment, there may be a problem with the codeRule 4: Comments should dispel confusion, not cause itRule 5: Explain unidiomatic code in commentsRule 6: Provide links to the original source of copied codeRule 7: Include links to external references where they will be most helpfulRule 8: Add comments when fixing bugsRule 9: Use comments to mark incomplete implementationsConclusionMemes and cartoons
2 Comments

Sort: