Skip to main content
Clean Code 50 XP · 5 min

Comment Heuristics

Identify and eliminate bad comments; write the rare good one with precision.

Showing
Ad (728×90)

The Five Comment Smells

C1: Inappropriate Information — use version control for history, not comments. C2: Obsolete Comment — stale comments are worse than no comments. C3: Redundant Comment — a comment that repeats the code adds noise. C4: Poorly Written — if a comment is worth writing, write it well. C5: Commented-out Code — delete it; git has history.

When to Comment

Good comments explain WHY, not WHAT. Legal notices, non-obvious intent, public API contracts, and TODO markers are acceptable. Everything else is a sign the code needs improving, not more comments.

Code Challenge

Name each comment smell (C1–C5) before seeing the fix.

Key takeaway

Comments are not documentation — they are apologies. Prefer expressive code that speaks for itself.

Done with this lesson?

Mark it complete to earn XP and track your progress.