Good Names Are the Cheapest Documentation

Precise naming aligns code with mental models and eliminates the need for redundant comments.

🌱 Seedling·created: ·updated: ·category:clean-code

A variable or function name is read a hundred times more often than it is written. Investing a few minutes to find the exact, unambiguous name pays dividends across the entire lifetime of a codebase.

Rules of Thumb

  • Name by intent, not implementation: isEligibleForDiscount() rather than checkUserFlagsAndOrderTotalGreaterThanFifty().
  • Avoid vague nouns: Names like Manager, Processor, Helper, and Data obscure true domain responsibility.
  • Match precision to scope: Loop indices can be i for a 2-line loop, but package-level types must be crystal clear.

Related thoughts on module clarity: abstractions-hide-complexity.

This note is part of the Digital Garden — a collection of connected, evolving thoughts.