Avoid Jumbled Acronyms for Clarity
TL;DR: Treat acronyms like normal words to improve human readability.
Treat acronyms as Capitalized words
Use camelCase or snake_case
Acronyms in uppercase (like JSON, XML, REST) in camel case break the natural reading flow.
You may think sendJSONRequestOnHTTPREST is a clear name, but it makes your code harder to read, especially when you string multiple acronyms together.
Treating acronyms like normal words in camelCase (sendJsonRequest) keeps your code more readable and easier to understand.
class NetworkConnector {
func validateXMLFile() { /*...*/ }
func sendJSONRequest() { /*...*/ }
func parseURLResponse() { /*...*/ }
func setRESTAPIURL() { /*...*/ }
func retrieveHTTPStatusCode() { /*...*/ }
func updateDBConnection() { /*...*/ }
func configureSSLCertificate() { /*...*/ }
func setHTMLTemplate() { /*...*/ }
func generateUUID() { /*...*/ }
func connectViaFTP() { /*...*/ }
}
class NetworkConnector {
func validateXmlFile() { /*...*/ }
func sendJsonRequest() { /*...*/ }
func parseUrlResponse() { /*...*/ }
func setRestApiUrl() { /*...*/ }
func retrieveHttpStatusCode() { /*...*/ }
func updateDbConnection() { /*...*/ }
func configureSslCertificate() { /*...*/ }
func setHtmlTemplate() { /*...*/ }
func generateUuid() { /*...*/ }
func connectViaFtp() { /*...*/ }
}
It would help if you had a smart thesaurus.
To detect this smell, look for methods or variable names with uppercase acronyms that disrupt readability.
Code reviewers or linters can also flag camelCase inconsistencies.
Modern AI code generators may produce inconsistent acronym casing.
Always review and adjust their output to match your conventions.
With prompts, AI can fix these naming issues and suggest improvements based on the camelCase style.
Remember: AI Assistants make lots of mistakes
Without Proper Instructions |
With Specific Instructions |
---|---|
Naming conventions are key to readable code.
Treat acronyms like normal words, and avoid uppercase blocks to keep your code easy to understand.
https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxxii
https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-x-i7r34uj
Code Smells are my opinion.
Photo by Csabi Elter on Unsplash
Thank you @Daniel Moka for this tip.
Simple can be harder than complex
Steve Jobs
This article is part of the CodeSmell Series.