12 Counterproductive Coding Practices That Kill Readability
The article enumerates twelve common defensive coding habits—like per‑table microservices, overly long methods, deep nesting, misleading comments, and unnecessary frameworks—that degrade readability and increase maintenance effort, illustrating each with a fictional programmer’s missteps and their impact on teams.
After years of handling messy codebases, the author lists twelve defensive coding “techniques” that actually reduce readability and increase maintenance difficulty.
1. Splitting microservices per table
The programmer treats each database table as an independent microservice, creating a sprawling architecture with many RPC calls, version conflicts, and performance problems.
2. Refactoring code but not releasing to production
New logic is hidden behind a feature switch that is only enabled in the test environment, causing confusion when new developers assume the code is live.
3. Writing excessively long methods
Methods longer than a thousand lines are believed to be more coherent, but they become unreadable and hard to maintain.
4. Deeply nested control structures
Control flow with more than ten nested if/try/else blocks makes the code virtually impossible to follow.
5. Random variable naming
Variables are named arbitrarily (e.g., str1, list2) without reflecting business meaning, leading to confusion later.
6. Misleading comments
Comments are deliberately written with incorrect information, swapping true/false statements or reversing meanings.
7. Changing code without updating comments
Code is modified while the original comments remain unchanged, resulting in mismatched documentation.
8. Copy‑pasting code
Code blocks are duplicated without proper refactoring, causing duplicated logic and hidden bugs.
9. Ignoring technical design documents
Detailed design diagrams are produced, but the actual implementation deviates significantly, leaving developers confused.
10. Refusing to add logging
The programmer never adds logs, making production troubleshooting extremely difficult.
11. Over‑engineering with heavyweight frameworks
Complex rule‑engine frameworks are introduced to solve simple strategy‑pattern problems, unnecessarily complicating the system.
12. Reinventing the wheel
Instead of using proven libraries, custom solutions like a homemade distributed lock are built, which often introduce new issues.
Summary
These twelve practices lower code readability and increase maintenance effort; developers should avoid them.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
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.
