📖 Business
Biz - Meaningful Names
Martin's argument that names are the single most pervasive communication tool in code. Every variable, function, class, module, and file has a name, and every name is either helping or hurting the reader's comprehension. The investment in choosing good names pays compound interest: every future reader saves seconds per encounter, and those seconds multiply across every developer on the team, every day, for the lifetime of the code. Naming is not a cosmetic concern — it is a core design activity.
2
Minutes
2
Concepts
+45
XP
1
How It Works

The eight naming rules:

  1. Use intention-revealing names. d is meaningless. elapsedTimeInDays is clear. The name should answer: why does this exist, what does it do, how is it used?
  2. Avoid disinformation. accountList should actually be a list. Don't use hp for hypotenuse if hp also means Hewlett-Packard in your domain. Don't use names that look similar (XYZControllerForEfficientHandlingOfStrings vs XYZControllerForEfficientStorageOfStrings).
  3. Make meaningful distinctions. a1, a2, a3 tells the reader nothing. source and destination tell the story. Noise words like Info, Data, Manager are flags that the name isn't specific enough.
  4. Use pronounceable names. genymdhms (generation date, year, month, day, hour, minute, second) forces every conversation to use a made-up word. generationTimestamp lets people talk about the code naturally.
  5. Use searchable names. Single-letter names and numeric constants are impossible to grep. MAX_CLASSES_PER_STUDENT is instantly findable. 7 is not.
  6. Avoid encodings. Hungarian notation (strName), member prefixes (m_description), and interface prefixes (IShapeFactory) are noise that modern IDEs have made obsolete.
  7. Class names should be nouns, method names should be verbs. Customer, WikiPage, Account (not Manager, Processor, Data). postPayment, deletePage, save (not doWork, process).
  8. One word per concept. Don't use fetch, retrieve, and get interchangeably across the codebase. Pick one and use it consistently. Inconsistency forces readers to remember which synonym applies where.