TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to Write Unmaintainable Code (1999)

159 pointsby dhuramasover 9 years ago

22 comments

Someoneover 9 years ago
They are missing the creatieve use of your version control system.<p>First, make sure none of your commits actually build out of the box; forget a file for a few revisions, accidentally check in a corrupted XML file, etc.<p>Create a &quot;trunkV2&quot; directory, and keep committing to both trunk and trunkV2. Add a third trunk inside the &quot;branches&quot; tree (&#x2F;branches&#x2F;featureX&#x2F;newTrunk; I have seen this n practice, with random customer branches sprinkled in)<p>In the tree of the service that your program calls, do something different, for example by starting with a simple tag &#x27;V1 frozen&#x27;, adding the revisions of the V2 version and then occasionally unfreezing the V1 one by committing a combined &quot;undo everything since V1&quot; and &quot;tiny fix to the v1 protocol that we thought was frozen&quot;, followed by an &quot;undo that, and do something else&quot; commit. Make sure to comment those commits as &quot;version for customer X&quot; and &quot;bug fix #3 for customer Y&quot;; do not mention &quot;V1&quot; or &quot;V2&quot;.<p>Also, make sure that &quot;customer X&quot; has both V1 and V2 deployed, so that future developers cannot learn that &quot;customer X&quot; implies &quot;version 2&quot;.
评论 #10238279 未加载
评论 #10238011 未加载
评论 #10237963 未加载
评论 #10238073 未加载
评论 #10239109 未加载
评论 #10238900 未加载
评论 #10239110 未加载
评论 #10238304 未加载
buro9over 9 years ago
They&#x27;ve missed the liberal use of dependency injection, triggers, or anything that can create a side effect of an event without being documented in the function being executed.<p>Much fun to be had there. Even just setting up PostgreSQL partition tables can defeat the most diligent maintainer (as they suddenly find RETURNING id_column fails everywhere).
macca321over 9 years ago
There&#x27;s only one rule:<p>1. Don&#x27;t write fast running behavioural tests that verify the software is working as required.<p>With fast running tests I can maintain any old crap. Well, technically speaking I can rewrite it, but no-one will mind.
评论 #10238745 未加载
评论 #10239298 未加载
评论 #10240927 未加载
runholmover 9 years ago
&quot;Hugh McDonald, hughmcd@ican&quot;<p>The guy has an e-mail address hosted at a top level domain. 1999 was a silly time.
评论 #10238713 未加载
arethuzaover 9 years ago
I&#x27;ve thought a particularly effective approach is actually to do the &quot;right&quot; thing but take it to ridiculous lengths - the &quot;Enterprise FizzBuzz&quot; that was posted on HN recently being a good example of this.
评论 #10241737 未加载
评论 #10238876 未加载
davecridlandover 9 years ago
Also a later version at <a href="http:&#x2F;&#x2F;www.stateslab.org&#x2F;HowToWriteUnmaintainableCode-Green00.html" rel="nofollow">http:&#x2F;&#x2F;www.stateslab.org&#x2F;HowToWriteUnmaintainableCode-Green0...</a> which includes that crazy offbeat language, JavaScript (which was, amusingly, my contribution).
sbovover 9 years ago
&gt; E.g. on the screen label the field &quot;Postal Code&quot; but in the code call the associated variable &quot;zip&quot;.<p>If you support multiple countries this is probably an inevitability. Same with province vs state, potentially others.<p>I guess you could have one variable called &quot;postalCode&quot; and one called &quot;zip&quot;, but that seems potentially more confusing.<p>Also, sometimes your UI shifts - should all your code change then? Because the boss wants to call something different in the UI? &quot;We were calling them admins, now we want to call them CSR.&quot; Is it time to write a regexp to rename everything?
评论 #10240445 未加载
JayOtter2over 9 years ago
I had Susan as a tutor in my first year at Imperial. This made me chuckle.
评论 #10238217 未加载
nippooover 9 years ago
My favourite one must be number 20. Best ever quote of Thumper I&#x27;ve seen...!<p>&quot;Never document gotchas in the code. If you suspect there may be a bug in a class, keep it to yourself. [...] Remember the words of Thumper &quot;If you can&#x27;t say anything nice, don&#x27;t say anything at all&quot;. What if the programmer who wrote that code saw your comments? What if the owner of the company saw them? What if a customer did? You could get yourself fired.&quot;
emersonrsantosover 9 years ago
How about obfuscated MUMPS?<p>P R I N T S (A,L)=1,(S,T)=I N G G I V E N A O F A=L:L:S Q:U=A R E S B=E L O W (A*A),! I S (U,R,E)=T H 1 N K I T=S G O O D
评论 #10238181 未加载
wellpastover 9 years ago
And yet give me a code base with clear contracts, narrow interfaces and minimal dependencies with EVERY ONE of these so-called &#x27;violations&#x27;...all of which are are trivial to contend with if you have a good software architecture.<p>Am wondering when our industry will see this forest for the trees...
sdf45over 9 years ago
While the advice in the article is funny, on a deeper level the author seems to argue that program text is a rather basic representation that often obstructs insight into the semantics of the program.<p>The quest for other program representations is still open. The state of the art uses text as &quot;storage&quot; format plus an IDE that does some semantic analysis to help the developer navigate. Many of the ideas mentined in the article (navigation, coloring, auto-format) have been integrated into IDEs and editors.<p>With almost 20 years of research between the article then and now, what semantic techniques are you dreaming of in your development environment? What are you missing? What feature would greatly improve your productivity (but is possibly too costly to implement by yourself)?
adrianNover 9 years ago
Also relevant The Selfish Class[1]. How to write classes that thrive in the struggle for programmer attention.<p>[1] <a href="http:&#x2F;&#x2F;www.laputan.org&#x2F;selfish&#x2F;selfish.html" rel="nofollow">http:&#x2F;&#x2F;www.laputan.org&#x2F;selfish&#x2F;selfish.html</a>
vogover 9 years ago
<i>&gt; You earn extra Brownie points whenever the beginning and end of a block appear on separate pages in a printed listing.</i><p>I&#x27;m aware that this is from 1997-1999, but I&#x27;m curious: Do people still print out source code for better reading?
评论 #10237931 未加载
评论 #10240538 未加载
评论 #10237969 未加载
评论 #10238272 未加载
评论 #10237930 未加载
评论 #10239287 未加载
评论 #10239891 未加载
评论 #10239339 未加载
评论 #10238549 未加载
评论 #10238147 未加载
评论 #10239075 未加载
评论 #10237904 未加载
samspotover 9 years ago
Look! Responsive Web Design from 1999!
littletinmanover 9 years ago
This should be renamed to: &quot;Common red flags to look for in merge requests and code reviews&quot; and handed to every rookie, mid-level, and senior developer on your project!
评论 #10239828 未加载
JoeCoder_over 9 years ago
I once worked with a programmer who would not indent any of his code. &quot;It makes it go faster&quot; he said. Wrote all of his code in Windows Notepad too.
returntripover 9 years ago
I&#x27;ve found it helpful to write several functions with the same name throughout the codebase. Also, when refactoring code, don&#x27;t rewrite it completely, just clone the directory and append &quot;_new&quot;.
cosmolevover 9 years ago
Writing unmaintainable code increases job security.
评论 #10242470 未加载
fgtxover 9 years ago
&quot;Never put in any { } surrounding your if&#x2F;else blocks unless they are syntactically obligatory.&quot;
landmark2over 9 years ago
genius! :)
emailgregnover 9 years ago
use perl
评论 #10237912 未加载