12 Coding Anti‑Patterns That Destroy Readability (And How to Avoid Them)
The article lists twelve harmful coding habits—from over‑splitting microservices and writing massive methods to ignoring logs and reinventing the wheel—that dramatically reduce code readability and increase maintenance difficulty, illustrating each with real‑world consequences.
1. Over‑splitting microservices – one service per table
The developer embraces microservice architecture to the extreme, creating a separate service for every database table. This results in a sprawling system with dozens of services, heavy RPC calls, version conflicts, and a steep learning curve for newcomers who must modify many services for a single feature.
2. Refactoring without releasing to production
After refactoring, a new logic flag is added but only enabled in the test environment. When the flag is not turned on in production, the new code fails, forcing the team to revert to the old implementation and causing delays and overtime.
3. Writing excessively long methods
The programmer believes that longer methods are more coherent and showcase skill, so he writes methods that exceed a thousand lines and never extracts smaller, reusable functions, making the code hard to understand and maintain.
4. Deeply nested control structures
He nests if/else/try‑catch blocks ten or more levels deep, claiming the code has no bugs. New team members find the nesting incomprehensible and are forced to seek explanations instead of reading the code.
5. Random variable naming
Variables are named arbitrarily (e.g.,
str1,
list2) without reflecting business meaning. The developer can remember them initially, but months later the names become meaningless, hindering debugging.
6. Adding misleading comments
Comments are deliberately written with opposite meanings or swapped between sections, leading readers to draw incorrect conclusions about the code’s intent.
7. Changing code without updating comments
When the code is heavily refactored, the existing comments are left untouched, resulting in a mismatch where comments describe outdated behavior while the implementation has changed.
8. Copy‑pasting code instead of refactoring
To save time, the developer copies existing code blocks verbatim across the project. This creates duplicated logic, and when a bug is fixed in one place, the other copies remain faulty.
9. Ignoring technical design documents
Although detailed design documents are produced, the actual implementation deviates significantly, using simpler or entirely different solutions, which confuses newcomers who rely on the documentation.
10. Not writing any logs
Confident that the code will never fail, the developer omits logging. When a production issue occurs, there is no trace except the stack trace, making root‑cause analysis extremely difficult.
11. Introducing heavyweight frameworks for trivial problems
The programmer imports complex rule‑engine frameworks to solve simple strategy‑selection logic, overcomplicating the system and increasing maintenance overhead.
12. Reinventing the wheel
Instead of using a proven library like Redisson for distributed locks, he implements his own lock with
SETNX, which later leads to reliability problems.
Conclusion
These twelve practices severely degrade code readability and maintainability; developers should avoid them to keep software clean and scalable.
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.