📖 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:
- Use intention-revealing names.
dis meaningless.elapsedTimeInDaysis clear. The name should answer: why does this exist, what does it do, how is it used? - Avoid disinformation.
accountListshould actually be a list. Don't usehpfor hypotenuse ifhpalso means Hewlett-Packard in your domain. Don't use names that look similar (XYZControllerForEfficientHandlingOfStringsvsXYZControllerForEfficientStorageOfStrings). - Make meaningful distinctions.
a1,a2,a3tells the reader nothing.sourceanddestinationtell the story. Noise words likeInfo,Data,Managerare flags that the name isn't specific enough. - Use pronounceable names.
genymdhms(generation date, year, month, day, hour, minute, second) forces every conversation to use a made-up word.generationTimestamplets people talk about the code naturally. - Use searchable names. Single-letter names and numeric constants are impossible to grep.
MAX_CLASSES_PER_STUDENTis instantly findable.7is not. - Avoid encodings. Hungarian notation (
strName), member prefixes (m_description), and interface prefixes (IShapeFactory) are noise that modern IDEs have made obsolete. - Class names should be nouns, method names should be verbs.
Customer,WikiPage,Account(notManager,Processor,Data).postPayment,deletePage,save(notdoWork,process). - One word per concept. Don't use
fetch,retrieve, andgetinterchangeably across the codebase. Pick one and use it consistently. Inconsistency forces readers to remember which synonym applies where.