12 Toxic Coding Habits That Destroy Readability (And How to Avoid Them)
The article humorously outlines twelve detrimental coding habits—from over‑splitting microservices to avoiding logs—that cripple readability and maintainability, illustrating each with a fictional programmer “Er Gou” and warning developers not to follow these anti‑patterns.
1. Over‑splitting microservices: one table per service
Er Gou embraces microservice design, believing each service can be developed and deployed independently. He takes it to the extreme, turning every database table into its own microservice, resulting in a sprawling architecture that overwhelms newcomers with dozens of services, excessive RPC calls, version conflicts, and a cumbersome deployment process.
2. Refactoring without releasing to production
Er Gou proudly refactors code and adds comments like "This is the new logic" , but only enables the new logic in the test environment. A new teammate, unaware of the switch, modifies the code based on the comment, which works in testing but fails in production, leading to missed deadlines and frustration.
3. Writing excessively long methods (over 1000 lines)
Er Gou believes that longer methods are more coherent and showcase skill. He repeatedly adds large blocks of code to existing methods instead of extracting reusable functions, making the codebase hard to understand and maintain.
4. Deeply nested control structures (10+ levels)
Er Gou nests multiple if/else/try‑catch blocks, claiming the code has "high quality" despite its complexity. New developers struggle to follow the logic, often needing extra help just to comprehend the flow.
5. Random, meaningless variable names
Viewing naming as an art, Er Gou assigns arbitrary names like str1, list2, etc., which he can remember temporarily but later forgets, causing confusion for anyone maintaining the code.
6. Writing misleading comments
Er Gou deliberately writes comments that invert the truth (e.g., changing "yes" to "no"), swaps unrelated comment sections, and misleads readers, making it difficult for newcomers to grasp the intended behavior.
7. Never updating comments after code changes
While Er Gou meticulously rewrites code, he leaves existing comments untouched, resulting in a mismatch between code and documentation that perplexes other developers.
8. Copy‑pasting code liberally
Pressed for time, Er Gou copies existing code blocks instead of refactoring. This leads to duplicated logic scattered across the codebase, increasing the likelihood of bugs and making future changes error‑prone.
9. Writing detailed technical designs but ignoring them in implementation
Er Gou spends a lot of effort drafting complex technical proposals (e.g., a sophisticated Redis‑based inventory system) but then implements a much simpler, unrelated solution, leaving the documentation out of sync with the actual code.
10. Refusing to add logging
Confident that his code will never fail, Er Gou omits logging entirely. When a production issue occurs, the lack of logs hampers troubleshooting, leading to prolonged outages and blame‑shifting.
11. Introducing heavyweight frameworks for trivial problems
Er Gou adopts heavyweight rule‑engine frameworks (Drools, SPEL, etc.) to solve simple strategy‑selection logic, complicating the system and making it harder for teammates to understand and modify.
12. Reinventing the wheel
Passionate about building his own tools, Er Gou replaces proven libraries (e.g., using a custom set‑nx based distributed lock instead of Redisson), which introduces bugs and unnecessary maintenance overhead.
Conclusion
The above twelve practices significantly reduce code readability and maintainability. Developers should avoid these anti‑patterns to keep their codebases clean and sustainable.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
