Good Names Are the Cheapest Documentation
Precise naming aligns code with mental models and eliminates the need for redundant comments.
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 thancheckUserFlagsAndOrderTotalGreaterThanFifty(). - Avoid vague nouns: Names like
Manager,Processor,Helper, andDataobscure true domain responsibility. - Match precision to scope: Loop indices can be
ifor a 2-line loop, but package-level types must be crystal clear.
Related thoughts on module clarity: abstractions-hide-complexity.
Backlinks (2)