How To Write Unmaintainable Code 437
An anonymous reader writes "Make sure you're irreplaceable -' 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. '"
missing icon? (Score:5, Insightful)
not how it works. (Score:5, Insightful)
Assuming this is tongue-in-cheek. My experience has been no matter how poorly written or unmaintainable something is, it offers little insurance to the author for keeping a job. I've been handed the reins to maintain countless "gone" employees' code. And, if the code isn't maintainable and the program is important or desirable enough, companies just limp along with the deficiencies. I can't think of a single occasion where someone was kept because of fears of maintaining their code, nor where someone was brought back to maintain their 'unmaintainable' code.
(+/- 2 sigma complainers -- reply here)
Re:April Fool's Right???? (Score:1, Insightful)
When I was a plumber.... (Score:5, Insightful)
On the code side, things I wrote 10 years ago I look at and think who the F*** wrote this, but back to my plumbing, that was the first lesson I was "Taught" NEVER EVER Say something like who the hell did this this way and why, more often than not after being in the business IT WAS YOU !, sure enough about 6 major jobs I went on to think to MYSELF , who did this holy shit is this complex, well after a day on the job I realized it was ME!!!
Never say "Who the Hell wrote this" out loud...a sure way to hang yourself when you practice this method of job security.
Not So (Score:5, Insightful)
I have had way too many times in my contract work that I was assigned to upgrade unmaintainable code.
In fact, I earned a reputation as a saving grace and the original coder was never called back and he earned a black eye as a poor coder.
Now who do you think stayed on the job longer?
guilty as charged (Score:3, Insightful)
Its Funny. Laugh. And a jab at the IT industry. (Score:3, Insightful)
Did you miss the "Humor" tag?
Did you even read the article or are you responding to the blurb on the front page?
Its a jab at the IT industry (and an old one at that - been around for quite some time - this is the second time this thing has appeared on Slashdot that I can remember); think of it as an article on Worst Practices. No one is supposed to be doing these things; they are illustrations of things that *still* happen that should never be done - a humourous jab in the eye to get our attention and encourage *good* programming styles and techniques by highlighting the ridiculous stuff that does happen.
Re:I realize that it's supposed to be humor (Score:3, Insightful)
Biased, much? (Score:4, Insightful)
Who said he or she was an American? I've seen plenty of posts on Slasdhot writen in English from people who were not American. Biased, much?
Hard Drive Size... (Score:2, Insightful)
that there are people that think that way in the programming industry.
Not to start flaming, but I've always maintained that the expansive
hard drive sizes over the years certainly hasn't aided in the idea of
creating (and maintaining) tight, clean code. Yes, the topic has been
beat around a lot; however, it's perfectly valid. I certainly I have
spoken to more than a few long-time programmers that - though not
outright - have indicated that the leaps in hard drive space gave more
than a little breathing room in software development.
-Shawn
Re:If I were the manager... (Score:2, Insightful)
Using bad code to maintain your employment. (Score:5, Insightful)
priceless (Score:1, Insightful)
Anybody is Replaceable (Score:2, Insightful)
... *even those who spend all their time reading slashdot*
If you were the manager... (Score:1, Insightful)
You yourself would get fired for not having properly supervised the rogue programmer in the first place and prevented them from having sabotage-written the code and wasting the money spent on their salary that resulted in the development of a "defective" product. Then the money that would have been used to pay YOUR salary will next be used to hire someone who will rewrite the code... under close scrutiny this time.
Re:Hard Drive Size... (Score:3, Insightful)
hard drive sizes over the years certainly hasn't aided in the idea of
creating (and maintaining) tight, clean code.
Just to play devil's advocate for a moment, small hard drives and less powerful systems didn't exactly encourage readable code either. Unrolled loops, cycle saving "tricks", and millions of premature optimizations were a large part of the earlier days of computing.
Java is actually quite interesting because it's one of the first (the first?) languages to encourage readable code. Sadly, anyone who's been introduced to Microsoft C++ (Hungarian notation, damn underscores in front of everything, etc.) may be beyond hope of ever properly utilizing the language.
Re:And Microsoft rule (Score:3, Insightful)
I am amazed that so many people don't realize that this was a joke. It's a joke people. Are all of these people replying seriously 16? I have to suspect so, because this was immediately identifiable as the same sort of joke that has been repeating for years and years - if you've been in the industry more than a year, if anything it sounded cliched.
Having said that - there is some truth to the claims. The reality is that most programmers out there are terribly, terribly lazy, and they'll immediately declare as undecipherable any code that isn't written for a mentally handicapped pigeon. If you've ever developed code to solve a problem of any complexity at all (e.g. more than some sub-100 IQ CRUD type data forms), you've had it declared "spaghetti code" by someone else, and they've probably thrown up their hands and declared that the only solution is to rewrite it (I'm proud to say that I've had this said about some of my historical code. Not because it was written poorly, but rather because it wasn't just a lightweight, superficial wrapper around calls to library functions. Per the prior point, every lazy programmer would rather just write something new themselves than expend the effort understanding existing code). I've seen this in shops where the lazy, lazy, lazy developers always defer all decisions and judgements to the original programmer (and that original programmer is probably wishing they never had anything to do with it, wishing they stuck to implementing high-level scripts).
Re:guilty as charged (Score:3, Insightful)
I just can not stop using i as an index. My programing teacher learned FORTRAN first and when the taught me Pascal he used i in for loops so I do this day.
If 'i' is obfuscation of 'index' then 'for' is obfuscation of 'for_as_long_as_expression_between_semicolons_is_t rue'.
Re:guilty as charged (Score:3, Insightful)
So it's standard enough, I think.
Re:FoxPro for DOS 2.6 (Score:3, Insightful)
Can come back to bite you... (Score:2, Insightful)
Unmaintainable employee (Score:5, Insightful)
If the code is unmaintainable, the end product is probably bad. If the end product is bad, you're not protecting your job but making a case for your worthlessness. Even if the end product is good, most companies would favor a fresh, new person who can differentiate themselves from you by writing a more friendly, maintainable version of the same. When I have come in (back in my indie days) to update or maintain a system that is unmaintainable, I have always made a good case for a more ambitious bid (and more money) to recreate the system from scratch (or recreate as much of it as is necessary) in a more standard, maintainable format.
Besides, as all you open source geeks know, this is (job) security by obscurity, and while it may cause a major inconvienence for your employer, it's not going to force them to keep someone they want to can. IT kids are in for a rude awakening (or have already gotten one) if they think we're still in the era where you're irreplacable, where some other code monkey couldn't come in and do the same or better of a job of what you're doing for less money in a heartbeat.
Here's a hint, find a place that you actually ENJOY working for, that treats their employees well and isn't looking to pull the plug on them at the most convienent time.. And then give them the best work you can offer. Be willing to take the lumps as a line employee for a while and actually earn a career in that company.
Bad, BAD Advice! (Score:5, Insightful)
First rule of business: Don't be irreplaceable. If you can't be replaced, you can't be promoted!
Re:I 'm in this situation (Score:2, Insightful)
The article is somewhat amusing and does cover some interesting points that I've run into over the years. However, writing unmaintainable code just makes you even more likely to get fired.
Unmaintainable code just leads to bugs that can't be fixed without bringing the rest of the system to its knees.
Re:Jeez, just run an obfuscator (Score:2, Insightful)
Well, you know, there's an old saying along the lines of "to err is human, but to screw up really good you need a computer"; since programming is the yang to computer hardware's yin, I'd say "to make unmaintainable code you can use code generators, but to really screw up your code you need a human to write it". =)
Well-designed, but obfuscated, code is decipherable (in theory); code written without any coherence whatsoever, either due to lack of coding standards or due to different coders throwing together features without any planning, tend to be the most difficult to understand.
More than just a joke... it's a teaching tool (Score:4, Insightful)
And as for the maintainer interpretting it, you're absolutely right that most people just throw up their hands. It's hard to interpret someone else's code for anything past the trivial. Doable, but hard enough that rewriting it often is a good way. Heh, besides which, it's amazing how many times I've thrown up my hands, rewritten the code, and by the experience found that I understood the original code.
Insecure Programmers (Score:5, Insightful)
Re:FoxPro for DOS 2.6 (Score:1, Insightful)
Re:Until you get promoted ... (Score:3, Insightful)
Sounds like a way to learn a bad habit on top of a bad habit:
100 LOC
*/
= 2 LOC changed
= 100 LOC changed
Re:Lifetime aint always that long (Score:5, Insightful)
If you're paying someone to do a complex job (hint: if it costs $1 million to replace them, it's a complex job), and they die/quit/retire, find a smart person to replace them. Don't find two dipshits to replace them. Don't give Suzy the secretary a $2 raise to do their job (unless Suzy the secretary really is a smart person, in which case, why weren't you paying Suzy more to begin with?)
I've seen it happen over and over again. Smart person runs entire company single-handedly. Smart person quits/dies. Company panics. Company spends ungodly sum of money to completely redesign whatever it is the smart person was doing. New system ends up missing functionality and costing the company loss of productivity.
Every time, something tells me that if this person was smart enough to do everything they were doing, there was probably a reason for it. That's not to say they can't be replaced, just that they probably can't be replaced with any random dipshit, or any random piece of off-the-shelf software.
So, if you're a manager/owner, and you find yourself in this situation: when smart person quits, put an ad in the paper, hire a headhunter, find someone with an IQ of 130 to replace them. Pay them 20% more than you were paying the previous person. Don't worry about whether the new person has experience doing exactly what the previous person did. Don't worry about redesigning anything. If something needs to be changed, the new smart person will be perfectly capable of changing it.
Re:Lifetime aint always that long (Score:4, Insightful)
I've found Perl just perfect for that task! (Score:3, Insightful)
I've leared that the hard way, by starting my Perl education maintaining the code written by someone else. I've fought back by writing the number of apps in Perl, as well. Poor suckers kept calling me at my new job, long after I quit.