IntroductionThis is my most popular essay. It is amazing how many people don’t realise it is tongue in cheek
If builders built buildings the way programmers write programs, then the first woodpecker that came along would destroy civilization.
~ Gerald Weinberg(1933-10-27 age:84)Weinberg’s Second Law
Never ascribe to malice, that which can be explained by incompetence.This essay has been like rock candy, seed the string with sugar, soak in sugar water, soon it grew out of control.
~ Napoléon Bonaparte(1769-08-151821-05-05 age:51)
In the interests of creating employment opportunities in the Java programming field, I am passing on these tips from the masters on how to write code that is so difficult to maintain, that the people who come after you will take years to make even the simplest changes. Further, if you follow all these rules religiously, you will even guarantee yourself a lifetime of employment, since no one but you has a hope in hell of maintaining the code. Then again, if you followed all these rules religiously, even you wouldn’t be able to maintain the code!
You don’t want to overdo this. Your code should not look hopelessly unmaintainable, just be that way. Otherwise it stands the risk of being rewritten or refactored.
This giant essay has been split into sections to make it faster to load. The easiest way to navigate is to hit the next page button at the bottom left of each page.
I would like to remind you this essay is copyrighted material. It is illegal to repost it without permission. I will usually give you that permission if you translate the essay into another language and if you provide a link back to the English-language original. I do this for three reasons.
- That way any change I make to the essay is instantly reflected in any English-language copy anyone reads.
- That way the formatting and images are preserved. Pirated copies usually screw up the formatting.
- Google ad revenue from this essay is the main source of income from the website. It pays to keep me on the air.
Please report any copyright violations.
naming methods and variables
Programmer Humor: How to Write Unmaintainable Code
Recently I saw a humorous guide on GitHub titled, How To Write Unmaintainable Code. GitHub is primarily a repository for open source software, and therefore serves as a bastion for programmer humor. The author of the guide is claiming to be “passing on these tips from the masters on how to write code that is so difficult to maintain, that the people who come after you will take years to make even the simplest changes” so you can “Ensure a job for life”. While the guide is geared towards Java programming, most of the “tips and tricks” apply to all realms of coding. As an integrator the maintainability of the code is equally as important as functionality, so several of the points (listed below) particularly resonated with me.
A.C.R.O.N.Y.M.S. – “Use acronyms to keep the code terse. Real men never define acronyms; they understand them genetically.”
Code Names Must Not Match Screen Names – “Choose your variable names to have absolutely no relation to the labels used when such variables are displayed on the screen. E.g. on the screen label the field “Postal Code” but in the code call the associated variable “zip”.”
Lie in the comments – “You don’t have to actively lie, just fail to keep comments as up to date with the code.”
Long Lines – “Try to pack as much as possible into a single line.”
Testing is for cowards – “A brave coder will bypass that step.” “If we have full confidence in our coding ability, then testing will be unnecessary.”
Although the full guide is a long read, I highly recommend at least giving it a browse. What are some things you’ve seen that make code horrendously unmaintainable?
Image Source: Freepik