How to Write Unmaintainable Code: A Satirical Guide for Developers
This tongue‑in‑cheek article lists a series of deliberately bad coding practices—ranging from confusing naming conventions and deceptive comments to abusive design choices and omitted testing—intended to illustrate how developers can make their software virtually impossible to maintain.
1. Program Naming
Easy‑to‑type variable names . For example: Fred, asdf.
Single‑letter variable names . For example: a, b, c, x, y, z (or a1, a2, … if needed).
Creative misspellings . For example: SetPintleOpening, SetPintalClosing, making code hard to search.
Abstract names . For example: ProcessData, DoIt, GetData… so vague they say nothing.
Acronyms . For example: WTF, RTFSC, or even Chinese pinyin abbreviations like BT, TMD, TJJTDS.
Random capital letters . For example: gEtnuMbER.
Reuse names . Using the same variable name in nested blocks for “effect”.
Accent characters . For example: int ínt (the second ínt is not int).
Underscores . For example: _, __, ___.
Mix languages . Combine English, German, or Chinese pinyin.
Symbolic names . For example: slash, asterix, comma.
Irrelevant words . For example: god, superman, iloveu.
Confuse l and 1 . The letter l and digit 1 can be indistinguishable.
2. Disguised Deception
Interleave comments and code .
for(j=0; j<array_len; j+=8) {
total += array[j+0];
total += array[j+1];
total += array[j+2];
/* Main body of
total += array[j+3]; * loop is unrolled
total += array[j+4]; * for greater speed.
total += array[j+5]; */
total += array[j+6];
total += array[j+7];
}Code and UI mismatch . UI shows “postal code” while code uses “zipcode”.
Hide global variables . Pass globals as function parameters to disguise them.
Similar variable names . e.g., swimmer vs swimner, ilI1|, oO08, parseInt vs parselnt.
Overloaded functions . Same name, unrelated implementations.
Operator overloading abuse . Overload ! to return an integer, then chain !!! for bizarre behavior.
3. Documentation and Comments
Lie in comments . Don’t update comments when code changes.
Write nonsense in comments . e.g., /* add 1 to i */.
Comment only the what, not the why .
Never comment secrets . Hide critical logic from documentation.
Over‑detail documentation . Write hundreds of pages with deep numbering.
Gotchas . Never comment on pitfalls.
Vent frustrations in comments .
4. Program Design
Java casts . Overuse type casting from collections.
Exploit Java redundancy . e.g., Bubblegum b = new Bubblegom();
Never validate . Skip input and return‑value checks.
No encapsulation . Expose all internal details.
Copy‑paste cloning . Duplicate code instead of understanding it.
Huge listeners . One listener with massive if‑else chains for all buttons.
Use three‑dimensional arrays . Even four‑dimensional if needed.
Mix getters/setters with public fields . Confuse maintainers.
Deep wrapper chains . Wrap APIs 6‑8 times, depth >4.
Make everything public . No access restrictions.
Swap parameter order repeatedly . e.g., drawRectangle(height, width) then reverse.
Rename methods arbitrarily . setAlignment → setLeftAlignment, setRightAlignment, etc.
Keep dead code . Preserve unused variables, methods, classes.
Finalize all subclasses . Prevent inheritance extensions.
Avoid layout managers . Hard‑code GridBagLayout coordinates.
Scatter environment‑variable initialization . Initialize members via env vars in unrelated functions.
Mislead configuration files . Parameter names differ from code.
Inflate classes . Pack many unrelated methods into one class.
Deep inheritance hierarchies . Ten levels for ten fields.
XML chaos . Replace short code with verbose XML.
Decompose conditions . a==100 → a>99 && a<101.
Abuse semicolons . if (a); else; { int d; d=c; }
Indirect casting . new Double(d).toString() instead of Double.toString(d).
Excessive nesting . >10 parentheses or >20 nested blocks.
Long code lines . Make lines as long as possible.
Avoid early returns . Use deep if‑else instead of break.
5. Testing
Never test . Skip error‑handling tests.
No performance testing . Blame the machine.
Don’t write test cases . Skip coverage and automation.
Call testing cowardly . Claim brave programmers don’t need tests.
6. Other
Obey the boss . Follow any unreasonable directive.
Hide bugs from support . Ignore user reports or blame the user.
Keep big secrets . Never disclose critical bugs.
Sell hype . Label bad code with GoF patterns or agile buzzwords.
In short, the motto is Write Everywhere, Read Nowhere .
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
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.