Inconsistent Names
Using different words for the same concept.
“Pick one word for one abstract concept and stick with it.” – Robert C. Martin
Signs of Use (Symptoms)
-
fetchUser(),retrieveOrder(),getProduct()all do similar “get” operations. -
Controller,Manager,Handlerused interchangeably.
Why it is bad (Consequences)
- Confusion: Are
fetchandgetdifferent? Is there a subtle distinction? - Discoverability: Developers search for
getUserbut it’sfetchUser.
Why it happens (Root Cause)
Multiple developers with different vocabularies. No agreed-upon naming convention.
When it might be okay (Exceptions)
- Technical distinction (HTTP
fetchvs DBget).
Explanation
Problem
Codebase uses fetch, get, retrieve, load for the same concept.
The Flaw
Inconsistency creates cognitive overhead.
Real world analogy
Calling directions “left”, “port”, and “westward” in the same conversation.
Refactoring Solution
- Rename Method: Standardize vocabulary.
- Agree on glossary.
Pros and Cons (of the Antipattern)
| Pros (Why people do it) | Cons (The price you pay) |
|---|---|
Comparison
- Related Antipatterns: Uncommunicative Name.
- Related Principles: Consistency.
Code example
Typescript
Bad (The Antipattern)
Good (The Fix)