Java naming conventions with acronyms: HttpClient or HTTPClient?
Codemia Knowledge Hub ·
Treat acronyms as ordinary words in camel case: HttpClient, XmlParser, getUserId, parseHtml. The exception is established platform types such as URL, URI and UUID, which you keep as the JDK spells them. Beyond that, consistency across the codebase matters more than any single rule.
Write acronyms as words by default
- classes:
HttpClient,XmlParser - methods:
getUserId,parseHtml - fields:
apiKey,dbUrl
Identifiers read like normal Java instead of blocks of capitals. Names like HTTPRequestHandler used everywhere are heavier and harder to scan.
Keep JDK types like URL and UUID as they are
The JDK itself uses URL, URI, UUID and XMLStreamReader. Once a type is an established platform concept, matching its spelling is clearer than forcing another one:
The type names stay URL and UUID, while the surrounding names read as getUrl() and requestId. That is usually easier to read than getURL() or requestID(). Copying JDK acronym style into every project-specific name, though, tends to hurt readability.
userId versus userID in getters
Accessors and JSON-style identifiers are where acronym style matters most:
versus:
The first fits Java naming expectations better and causes less friction with frameworks that infer bean properties from method names; ignoring those conventions can make frameworks behave unexpectedly. The same applies when an identifier has several acronyms: prefer parseJsonResponse over parseJSONResponse unless your team strongly prefers otherwise.
Pick a team rule and document the exceptions
No acronym rule is perfect, because real code mixes official style guides, JDK history, generated code and team preference. Mixing userId, userID and UserID in one codebase is what actually causes confusion. So:
- pick one default convention
- document the exceptions
- apply it uniformly
For example:
- use
Http,XmlandJsonin ordinary names - keep
URL,URIandUUIDwhen referring to JDK types
That rule is easy to understand and enforce in reviews, and writing it down saves having the same argument again later.
URL stays uppercase as a type, while the other identifiers follow the camel-case rule.
Related reading
- Java NIO FileChannel versus FileOutputstream performance / usefulness
- Java Non-Blocking and Asynchronous IO with NIO NIO.2 JSR203 - Reactor/Proactor Implementations
- Java notify() vs. notifyAll() all over again
- Java Open Source Text Mining Frameworks
- Java Ordered Map
- Java .parallelStream with spring annotated methods
- Java parse int value from a char
- Java Pass Method as Parameter
System design interview problems on this topic
- Design an API Rate Limiter: solution and walkthrough
- Design a Distributed Messaging System: solution and walkthrough
- Design an Online Payment Service: solution and walkthrough
- Design a Key Value Store: solution and walkthrough

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.