Code Smell 277 – UPPERCASE Acronyms

Treat acronyms like normal words to improve human readability.


This content originally appeared on HackerNoon and was authored by Maximiliano Contieri

Avoid Jumbled Acronyms for Clarity

TL;DR: Treat acronyms like normal words to improve human readability.

Problems

  • Reduced readability
  • Breaking naming style
  • Words confusion
  • Harder to pronounce

Solutions

  1. Treat acronyms as Capitalized words

    \

  2. Use camelCase or snake_case

Context

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.

Sample Code

Wrong

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() { /*...*/ }
}

Detection

  • [x] Semi-Automatic

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.

Tags

  • Code Standards

Level

  • [x] Beginner

AI Generation

Modern AI code generators may produce inconsistent acronym casing.

\ Always review and adjust their output to match your conventions.

AI Detection

With prompts, AI can fix these naming issues and suggest improvements based on the camelCase style.

Try Them!

Remember: AI Assistants make lots of mistakes

| Without Proper Instructions | With Specific Instructions | |----|----| | ChatGPT | ChatGPT | | Claude | Claude | | Perplexity | Perplexity | | Copilot | Copilot | | Gemini | Gemini |

Conclusion

Naming conventions are key to readable code.

\ Treat acronyms like normal words, and avoid uppercase blocks to keep your code easy to understand.

Relations

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

More Info

https://www.linkedin.com/posts/danielmoka_clean-code-tip-name-acronyms-as-normal-words-activity-7251472396438687744-C4kx/?embedable=true

Disclaimer

Code Smells are my opinion.

Credits

Photo by Csabi Elter on Unsplash

\ Thank you @Daniel Moka for this tip.


Simple can be harder than complex

Steve Jobs

https://hackernoon.com/400-thought-provoking-software-engineering-quotes?embedable=true


This article is part of the CodeSmell Series.

How to Find the Stinky Parts of your Code


This content originally appeared on HackerNoon and was authored by Maximiliano Contieri


Print Share Comment Cite Upload Translate Updates
APA

Maximiliano Contieri | Sciencx (2024-10-30T21:18:23+00:00) Code Smell 277 – UPPERCASE Acronyms. Retrieved from https://www.scien.cx/2024/10/30/code-smell-277-uppercase-acronyms/

MLA
" » Code Smell 277 – UPPERCASE Acronyms." Maximiliano Contieri | Sciencx - Wednesday October 30, 2024, https://www.scien.cx/2024/10/30/code-smell-277-uppercase-acronyms/
HARVARD
Maximiliano Contieri | Sciencx Wednesday October 30, 2024 » Code Smell 277 – UPPERCASE Acronyms., viewed ,<https://www.scien.cx/2024/10/30/code-smell-277-uppercase-acronyms/>
VANCOUVER
Maximiliano Contieri | Sciencx - » Code Smell 277 – UPPERCASE Acronyms. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/30/code-smell-277-uppercase-acronyms/
CHICAGO
" » Code Smell 277 – UPPERCASE Acronyms." Maximiliano Contieri | Sciencx - Accessed . https://www.scien.cx/2024/10/30/code-smell-277-uppercase-acronyms/
IEEE
" » Code Smell 277 – UPPERCASE Acronyms." Maximiliano Contieri | Sciencx [Online]. Available: https://www.scien.cx/2024/10/30/code-smell-277-uppercase-acronyms/. [Accessed: ]
rf:citation
» Code Smell 277 – UPPERCASE Acronyms | Maximiliano Contieri | Sciencx | https://www.scien.cx/2024/10/30/code-smell-277-uppercase-acronyms/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.