Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
It's funny.  Laugh. Programming IT Technology

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. '"
This discussion has been archived. No new comments can be posted.

How To Write Unmaintainable Code

Comments Filter:
  • missing icon? (Score:5, Insightful)

    by BushCheney08 ( 917605 ) on Monday November 21, 2005 @12:43PM (#14082431)
    Ummmm, where's the foot icon? It's good to know that the author considers this a joke, but I'm afraid that Hemos might not be in on it...
  • not how it works. (Score:5, Insightful)

    by yagu ( 721525 ) * <{yayagu} {at} {gmail.com}> on Monday November 21, 2005 @12:45PM (#14082453) Journal

    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)

  • by Anonymous Coward on Monday November 21, 2005 @12:46PM (#14082469)
    Whoa, talk about knee-jerk reaction. The article is obviously meant to address people who think this way, not an actual advocacy of this behavior. Also, on a slightly sadder note, being a great programmer/problem solver does not automatically guarantee you will be irreplacable; it'll just mean that a lot of the time, you'll be known as 'that guy'. Sometimes, it's the social skills that win the day, not just your abilities, no matter how obvious they might seem.
  • by MajorDick ( 735308 ) on Monday November 21, 2005 @12:50PM (#14082517)
    I used to employ similar tactics on large non-residnetial contracts, not for myself but for our company, I leared this from my Grandfather and Uncle who did the same, 40 years after the construction a hospital my Uncle was called out of retirment (as a consultant to the firm that got the expansion) To show them "the lay" his price tag $250,000 for 1 year at 35 hrs/wk. He is in the process of building a new home with the proceeds.

    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)

    by AnalogDiehard ( 199128 ) on Monday November 21, 2005 @12:50PM (#14082525)
    Writing unmaintainable code does not make you irreplaceable and does not sustain your work duration.

    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)

    by LWATCDR ( 28044 ) on Monday November 21, 2005 @12:51PM (#14082534) Homepage Journal
    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.
  • by C0deM0nkey ( 203681 ) on Monday November 21, 2005 @12:52PM (#14082539)
    My Lord, you just completely missed the point of that article, didn't you?

    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.

  • by slvi ( 628811 ) on Monday November 21, 2005 @12:52PM (#14082543)
    And what's more, why would you want to be bound to program for the rest of your useful life?!
  • Biased, much? (Score:4, Insightful)

    by Luscious868 ( 679143 ) on Monday November 21, 2005 @12:52PM (#14082548)
    Sheesh! Irony, it's lost on Americans!!

    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)

    by lostraven ( 928812 ) on Monday November 21, 2005 @12:53PM (#14082550) Homepage
    I agree that though intended to be "humour", it has to be recognized
    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
  • by DirePickle ( 796986 ) on Monday November 21, 2005 @12:53PM (#14082557)
    Ah, I see your sarcasm detector is turned off. You are already well on your way to managerial status!
  • by markv242 ( 622209 ) on Monday November 21, 2005 @12:55PM (#14082568)
    The kind of coder who deliberately writes bad code just to maintain their employment is always the first coder shown the door. Always. It is a complete urban myth that not commenting spaghetti code will keep you in a job. There is always someone else willing to do your job, no matter how specialized you think you may be.

  • priceless (Score:1, Insightful)

    by nubbie ( 454788 ) on Monday November 21, 2005 @12:56PM (#14082585) Homepage
    Priceless: Guaranteed to never get a promotion or pay raise!
  • by slashfun ( 831726 ) <vinson@slashmail.org> on Monday November 21, 2005 @12:58PM (#14082605) Homepage

    ... *even those who spend all their time reading slashdot* .....

  • by Anonymous Coward on Monday November 21, 2005 @01:00PM (#14082631)
    I would fire this person, and hire someone to rewrite the code from scratch.

    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.
  • by AKAImBatman ( 238306 ) <akaimbatman@gmaYEATSil.com minus poet> on Monday November 21, 2005 @01:04PM (#14082672) Homepage Journal
    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.


    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.
  • by ergo98 ( 9391 ) on Monday November 21, 2005 @01:10PM (#14082738) Homepage Journal
    The kind of coder who deliberately writes bad code just to maintain their employment is always the first coder shown the door. Always. It is a complete urban myth that not commenting spaghetti code will keep you in a job. There is always someone else willing to do your job, no matter how specialized you think you may be.

    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).
  • by psavo ( 162634 ) <psavo@iki.fi> on Monday November 21, 2005 @01:10PM (#14082742) Homepage

    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'.

  • by NilObject ( 522433 ) on Monday November 21, 2005 @01:21PM (#14082857)
    "i" is a standard indexing variable name. Anywhere it's used in code, you can usually assume that you;re doing some sort of scanning over an array of some sort.

    So it's standard enough, I think.
  • by rubycodez ( 864176 ) on Monday November 21, 2005 @01:33PM (#14082958)
    scary, my companies main quoting/billing system was also written in foxpro by the owner, maybe ok when the operation was a mom & pop retail computer store, but now they deal with enterprise grade systems and services. The application doesn't really scale, one person can sieze up the whole application for the whole company (over 30 employees and dozens of contractors). Note this is not saying a bad thing about Foxpro itself, I've seen financial trading companies use it for dozens of people, this mainly is saying our president should not be using his time to crank out/maintain code to run a company with a couple million in sales each year. Too cheap to buy an off-the-shelf app, and that's foolish.
  • by DreadfulGrape ( 398188 ) on Monday November 21, 2005 @01:34PM (#14082975)
    While I thought at one time that this was a good idea, actually if you choose to leave your coding job it can be a pain. My successor called me on the phone for almost 6 months asking "What does this do - what does this mean..." etc. until I finally had tell him "Man, I just don't remember anymore. Sorry!"
  • by wuice ( 71668 ) on Monday November 21, 2005 @01:45PM (#14083064) Homepage
    I know this article is somewhat tongue-in-cheek but it's actually a prevelant mentality. As someone who have watched people write unmaintainable code to ensure their own job security...

    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)

    by Roofus ( 15591 ) on Monday November 21, 2005 @01:48PM (#14083090) Homepage
    Make sure you're irreplaceable

    First rule of business: Don't be irreplaceable. If you can't be replaced, you can't be promoted!
  • by HikeFanatic ( 809939 ) on Monday November 21, 2005 @01:54PM (#14083133)
    Well spoken. As someone who's had the displeasure of having to work with unmaintainable code, it's not fun. In fact I threatened to quit unless they allowed me to write a large portion of the code base from scratch in order to make it scalable and more reliable.

    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.
  • by WWWWolf ( 2428 ) <wwwwolf@iki.fi> on Monday November 21, 2005 @02:13PM (#14083326) Homepage
    In skimming the article, I realized that an obfuscator does exactly what hes describing.

    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.

  • by SeanDuggan ( 732224 ) on Monday November 21, 2005 @02:14PM (#14083332) Homepage Journal
    I had a professor assign this essay as required reading for our Computer Science class. While none of us (hopefully) are deliberately employing the tricks and techniques in there, I'll bet every one of us can look through there and find one thing that we've been guilty of doing whether it was inane variable names, inaccurate comments, or bizarre variable scope issues. By reading through, it forces you to confront your laundry list of faults and decide which ones need to be fixed.

    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.

  • by mabu ( 178417 ) on Monday November 21, 2005 @03:01PM (#14083785)
    I find it really disturbing that programmers are so insecure they need to deliberately make their code difficult to understand. That's just stupid. If you're a good programmer, you will have job security. If you're a crappy programmer, all the obfusification in the world won't give you job security.
  • by Anonymous Coward on Monday November 21, 2005 @03:11PM (#14083866)
    True... but it has to be tempered with, "if it broke tomorrow, could you fix it?"
  • by Kjella ( 173770 ) on Monday November 21, 2005 @03:28PM (#14084009) Homepage
    Fortunately, their coding quality algorithm had to do with number of lines of code changed ... again, nothing to do with actual quality. Deleting redundant code merely enabled me and the software to work faster & better, which did not count as quality. When I learned to comment out redundant line, so they counted as "lines changed", my coding quality scores vastly improved!

    Sounds like a way to learn a bad habit on top of a bad habit:
    /*
    100 LOC
    */
    = 2 LOC changed

    // 100 LOC
    = 100 LOC changed
  • by benjamindees ( 441808 ) on Monday November 21, 2005 @03:51PM (#14084233) Homepage
    Why is this so difficult for employers to comprehend?

    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.
  • by AugstWest ( 79042 ) on Monday November 21, 2005 @04:41PM (#14084719)
    Have you ever tried to hire that One Smart Person? Hell, even if s/he existed, they'd never make it past HR.
  • by porky_pig_jr ( 129948 ) on Monday November 21, 2005 @06:35PM (#14085710)
    Perl, with its 'do the same thing gazillion different ways' is a perfect language to write completely unmaintaintable code.

    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.

The only possible interpretation of any research whatever in the `social sciences' is: some do, some don't. -- Ernest Rutherford

Working...