Advanced Code Comments #code-quality #anti-patterns

Comment Quality

6 exercises — spot anti-patterns (lying comments, obvious comments, journal comments, commented-out code) and rewrite them to high standard.

0 / 6 completed
Comment anti-patterns to spot
  • Obvious comment: restates what the code says ("add 1 to x")
  • Lying comment: describes different behavior than the actual code
  • Journal comment: changelog entries ("Alex, 2022: added X") — use git
  • Commented-out code: dead code — delete it; git preserves the history
  • Noise comment: vague ("this is important") — say WHY and what breaks if changed
  • Over-comment: dense comments on obvious code; justified only for non-obvious algorithms
1 / 6
Identify the anti-pattern in this comment:

x = x + 1; // add 1 to x