Skip to main content
Clean Code 60 XP · 6 min

Naming Heuristics

Apply the N1–N7 heuristics to write names that are accurate, unambiguous, and searchable.

Showing
Ad (728×90)

N1–N4: Precision and Clarity

N1: Choose descriptive names — a name should explain its purpose without a comment. N2: Choose names at the appropriate level of abstraction. N3: Use standard nomenclature where it exists (e.g., toString, compareTo). N4: Choose unambiguous names — avoid synonyms that mean the same thing.

N5–N7: Avoid Noise

N5: Use long names for long scopes, short names for tiny scopes. Don't pad names with type info (accountString, userList). N6: Avoid encodings — no Hungarian notation. Type systems make it redundant. N7: Names should not be obscure — if only the author understands a name, it's wrong.

Code Challenge

Match each bad name to its N-heuristic violation.

Key takeaway

A good name eliminates the need to read the implementation. Invest time in names — it pays compound interest.

Done with this lesson?

Mark it complete to earn XP and track your progress.