How to Write Code Nobody Can Maintain – A Satirical Guide
This tongue‑in‑cheek article enumerates a series of deliberately bad programming practices—from confusing naming conventions and deceptive comments to absurd design choices and zero testing—to illustrate how to make code virtually impossible to maintain.
1. Naming
Easy‑to‑type variable names – e.g., Fred , asdf .
Single‑letter names – e.g., a , b , c , or a1 , a2 …
Creative misspellings – e.g., SetPintleOpening , SetPintalClosing .
Abstract names – e.g., ProcessData , DoIt , GetData .
Abbreviations – e.g., WTF , RTFSC , or Chinese pinyin abbreviations like BT , TMD .
Random capitalisation – e.g., gEtnuMbER .
Reused names – using the same identifier in nested blocks.
Accent letters – e.g., int ínt (the second is not int ).
Underscores – e.g., _ , __ , ___ .
Mixing languages – combine English, German, or Chinese pinyin.
Character names – e.g., slash , asterix , comma .
Irrelevant words – e.g., god , superman , iloveu .
Confusing l and 1 – make them indistinguishable.
2. Deceptive Tricks
Interleave comments with code to hide intent.
<code>for(j=0; j<array_len; j+=8){
total += array[j+0];
total += array[j+1];
total += array[j+2]; /* Main body of
loop is unrolled for greater speed. */
total += array[j+3];
total += array[j+4];
total += array[j+5];
total += array[j+6];
total += array[j+7];
}</code>Code/display mismatch – UI says “postal code” while code uses zipcode .
Hide globals – pass global variables as function parameters to disguise them.
Similar variable names – e.g., swimmer vs swimner , ilI1| , parselnt vs parseInt .
Function overloading with unrelated behavior .
Operator overloading abuse – overload ! to return an integer, then chain !! or !!! for confusing effects.
3. Documentation and Comments
Lie in comments by not updating them.
Write useless comment text, e.g., /* add 1 to i */ .
Document *what* instead of *why*.
Avoid revealing secrets in comments (e.g., hidden flight‑system changes).
Over‑detail everything with massive hierarchical numbering.
Never comment traps or pitfalls.
Vent frustrations in comments and docs.
4. Design
Java casts – overuse type casting from collections.
Exploit Java redundancy – duplicate similar variables.
Never validate input or return values – trust everything.
Don’t encapsulate – expose all details to callers.
Copy‑paste cloning – avoid understanding code.
Huge listeners – a single listener with massive if…else chains.
Higher‑dimensional arrays – use 3‑D or even 4‑D arrays unnecessarily.
Mixed access – combine getters/setters with direct public field access.
Excessive wrapping – wrap APIs 6‑8 times, depth >4.
No secrets – make everything public .
Parameter order chaos – swap width/height repeatedly.
Rename variables arbitrarily – e.g., setAlignment to setLeftAlignment , etc.
Keep dead code – never delete unused variables or methods.
Seal classes with final – prevent inheritance.
Avoid layout managers – hard‑code absolute coordinates or GridBagLayout.
Environment‑variable initialization – initialise members from env vars instead of constructors.
Global variables everywhere – initialise them in unrelated functions.
Mismatched config names – config keys differ from code identifiers.
Bloated classes – overload a class with many obscure methods.
Subclass abuse – create deep inheritance hierarchies for each field.
XML bloat – replace short code with massive XML.
Decompose conditions – turn a==100 into a>99 && a<101 .
Semicolon tricks – e.g., if (a); else; { int d; d=c; } .
Indirect casting – new Double(d).toString() instead of Double.toString(d) .
Deep nesting – >10 parentheses or >20 nested blocks.
Long lines – make each line as long as possible.
Avoid early returns – use many nested if‑else instead of break .
Never use braces – omit {} even in complex if‑else structures.
Trivial encapsulation – wrap a bool in a full class.
Loop perversions – replace for with while , swap bounds, change < to <= , etc.
5. Testing
Never test error handling or system call returns.
Never perform performance testing; blame the hardware.
Avoid writing test cases or coverage metrics.
Consider testing cowardly; a “real” programmer needs no tests.
6. Other Tips
Obey a clueless boss to learn more ways to break maintainability.
Hide critical bugs from support staff and never acknowledge them.
Keep big bugs secret to profit later.
Label terrible code with design patterns or agile buzzwords to impress.
Write Everywhere, Read Nowhere – the ultimate motto of unmaintainable code.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
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.