Slashdot Mirror


How To Write Unmaintainable Code

/ writes "Roedy Green of Canadian Mind Products has written an essay entitled "How To Write Unmaintainable Code". Following his 54 tips, you too can guarantee job-security by becoming irreplaceable. If that weren't good enough, it's even available in Spanish. "

327 comments

  1. yes! by nicky+p · · Score: 1

    as a cs student, nothing inspires me more! job security rules!

    1. Re:yes! by uktimbo · · Score: 1

      I can't even get to this site via a T1 from the UK at 13.00 today! The Slashdot Effect in action.... Tim

  2. the secret to my success by CFN · · Score: 1

    I worked at the same web shop for 3 years while in college.
    What started off as a no pay internship turned into a $60/hour job, mainly because my code was valuable and it would have been impossible for someone else to figure out what I did and how it worked.
    Every time I mentioned other job offers, they just raised what they were paying me. It would have taken months for some fool to understand my code and do anything useful with it.
    I decided to continue in grad. school and I feel kinda bad leaving them with an expensive mess of spaghetti. If they pay $100/hour I'll spend my winter break making it understandable.

    1. Re:the secret to my success by Skim123 · · Score: 3
      Huh, that brings up an interesting point. What is better, to write crappy code or to take the time to make it nice and neat? From the programmer's perspective, it makes sense to write crappy code: bosses are demanding you finish projects before you even begin them, and good takes time to write; also, like you mentioned, job security is nice indeed.

      However, don't we, as programmers, have some sort of obligation to try our best to create nice, maintainable code? I may be getting a little too philosophical here, but we expect artists to paint to their best abilities, poets to write to their best ability. It seems like if someone in one of these professions purposefully wrote sloppy poetry, or half-assed a painting, that we would look down on them. Perhaps it is a pride thing, but you think you'd intrinsically want to write good code.

      I am not trying to sound preachy, CFN, for I don't know if you wrote sloppy code because you wanted to, or, more likely, because you were rushed and your superiors favored quantity of quality.

      --

      I could not justify my existence if I were a turkey farmer. Would I terminate myself? Undoubtably, yes.

    2. Re:the secret to my success by CFN · · Score: 1

      My code was a victim of constantly expanding project definition (CEPD).
      It was impossible to keep it nice b/c new features were requested so we could demo to some client, etc.
      Mgmt. was more concerned with showing it off that having it built soundly and they got what they paid for.
      It actually could have been nice, but whenever they felt I was "idle" (i.e. not showing them a new feature every 2nd day, but fixing what was behind the sceens) they would find a new feature to add or have me work on some other project.

    3. Re:the secret to my success by Anonymous Coward · · Score: 0

      The boss is always right. Let me say that again. The boss is always right. If they don't want to spend the money on high quality or easily maintained code, that is their decision. Not yours. ps. job security is a good thing :-)

    4. Re:the secret to my success by jmpvm · · Score: 1

      Artists and poets are usually not replaced on a whim because of a "cheaper" alternative (young college puke) comes around.

    5. Re:the secret to my success by notsoanonymouscoward · · Score: 2
      I feel your pain. I've basically implemented 90% of the "unmaintainable code" rules. Not because I was trying to, but because of the ever expanding "feature creap". My most favorite scenario:

      Friday:

      Me: Well I'm done with that latest addition you asked for. I'm going to clean the code up a bit and then head home.
      PHB: Oh that can wait, can you add -insert feature here- and have it up by the end of the day on monday?

      Its so hard to get mad when they're paying you that much. And in the end, it is job security ;)

      --
      I ate my sig.
    6. Re:the secret to my success by Anonymous Coward · · Score: 1

      Bull crap.

      The boss is often wrong. If you need to you can always explain why you boss is wrong to _his_ superiors.

      But you better be right and be able to prove it.

      The design process:

      1. Design the project. You need to know how to do something manually and explain how to do that process to an eight year old or your code will look like crap.

      2. Everyone agrees to _that_ project and signs off on it. This means that when someone changes the project it is a whole new ball game.

      3. Write the code. This is the only point that you actually write any code. Anyone who starts writting code at step one is a moron.

      4. Test your changes individually and collectively with the users to ensure that the project matches the plan. Everyone signs off on this.

      5. Document everything. The original plan will have time for documentation.

      6. Implement your changes.

      7. Post implementation support forever. It is easy to get overworked because each and every one of the projects that you implement needs to be supported. Every project that you complete adds a couple of hours of support time every week. By the time a coder has completed 30 projects he is so bogged down in production support that he is no longer useful in completing new projects.

      In our shop the programmers forced management to have code and documentation clean up days every month where we had a clear plan in the morning and we all worked together to complete that plan.

      A couple of examples of this is when we rewrote the batch documentation, or when we got rid of all the #ifdef DEBUG code out of our code so that we could actually install to a production box without having the DEBUG flag set.

    7. Re:the secret to my success by Anonymous Coward · · Score: 0

      2. Everyone agrees to _that_ project and signs off on it. This means that when someone changes the project it is a whole new ball game.

      Real life situation: they refuse to sign your specifications. They agree that the specs are right, but they don't sign. You don't want to proceed without that sign-off, naturally. But your boss (and his boss) order you to write code anyway. You have a choice: proceed or quit your job.

      All these nice little rules are fine and dandy in the textbooks, but reality doesn't play by those rules.

    8. Re:the secret to my success by Anonymous Coward · · Score: 1
      The boss is often wrong. If you need to you can always explain why you boss is wrong to _his_ superiors.

      Uh, do you realize that your boss's boss is the guy that hired/promoted your boss?

      Do realize that in order to acknowledge that you are right your boss's boss is going to have to say your boss is wrong?

      Believe me, your boss's boss is very aware of the implication of that!

      I'll spell that implication out for those who aren't familiar to corporate politics: your boss's boss made a mistake in hiring/promoting your boss. By saying you are right, he has to make a public admission that he hired/promoted the wrong guy. Errors of that magnitude are career killers.

      Why? Firing a bad employee is much more expensive than hiring a good employee. This is because the expense of hiring a good replacement employee is part of the cost of getting rid of the bad employee.

      On top of that expense you have the costs of carefully documenting why the employee was fired. Even so, the odds are not insignificant that you will be sued for wrongful dismissal and thereby incur court costs and associated administrative costs.

      Dilbert has it right: employees are promoted until they can do no damage. Another motivation at work here is: never promote a competent employee who someday may get the promotion that should have been yours.

    9. Re:the secret to my success by Anonymous Coward · · Score: 0

      That's awesome - I truly envy you. You should try and "enslave" as many companies as possible and make them keep you on retainer. I got a free T1 to my house that way!

    10. Re:the secret to my success by Anonymous Coward · · Score: 0
      Exactly. The problems are with management, not the developers. They want things done NOW, not done right - even if they claim otherwise. If it takes 2 weeks to do something right or 2 days to put together some quick hack and the demo is next monday, you can guess what option you'll both be choosing.

      Remember, when stuff gets too out of control you can always move on. Your messes don't have to be your problem forever.

  3. Coding by pvthudson · · Score: 1
    I don't know if its funny or scary. Ya job security is a nice thing, but come on people write decent code.

    --


    Its karma, Kramer.

  4. The prize goes to... by Skim123 · · Score: 2
    The funniest one, by far, I thought, was: Make sure that every method does a little bit more (or less) than its name suggests. As a simple example, a method named isValid(x) should as a side effect convert x to binary and store the result in a database.

    That had be laughing outloud! Being a web developer, I have often had to work with code that tried to do many, many thing. One web page would try to accomplish thirty different things, based solely upon the querystring parameters passed in. Ugh. Now there's job security! :)

    --

    I could not justify my existence if I were a turkey farmer. Would I terminate myself? Undoubtably, yes.

  5. Maybe you shouldn't be working for the place. by E-TiE · · Score: 4

    Writing unmaintainable code for job security is a Bad Idea (TM). Cuz guess what? You might end up the victim of your own practices -- and who's going to get fired when they've failed to figure out code they wrote a year ago? You. Don't do it. Maye you should work somewhere else where they know how much you're important and valuable to them, so you don't have to take such measures as to write bad code. And if you're going to get replaced so easily then maybe you were not worth your salt in the first place.
    ------------------------------------------ -----

    --
    -----------------------------------------------
    Unix _is_ user friendly, it's just particular about who its friends
    1. Re:Maybe you shouldn't be working for the place. by Crouchy · · Score: 3

      Rule of thumb here.. Write two sets of code, one with utter drivel, the other well maintained.
      One you don't shoot yourself in the foot..
      Two you have job security...

    2. Re:Maybe you shouldn't be working for the place. by E-TiE · · Score: 1

      Why write two sets of code just for the sake of job security? Makes you half as productive and ever tried understanding bad code from the good equivalent? It's just seems pointless to me. Just do youself a favor a write good code to begin with and stick to it.
      --------------------------------------------- --

      --
      -----------------------------------------------
      Unix _is_ user friendly, it's just particular about who its friends
    3. Re:Maybe you shouldn't be working for the place. by kijiki · · Score: 1

      Good programming practice is to automate as much as possible. Many of these rules could be applied by a program. modifiy your checkin routine to automatically obfuscate your code every time you check it in.

    4. Re:Maybe you shouldn't be working for the place. by GC · · Score: 2

      I have done this in the past and I had a good reason for it:

      I was working in a PC Support role at the time and there was no mention of programming in my contract. I was, however, asked to write and maintain some programs written in Visual Basic for Excel. No agreement was made to provide them with the source code to the program, but it isn't possible to not provide them with the source code and VB for Excel is Interpreted at runtime and not compiled. Hence they would receive the code no matter what. I wrote well structured code where all variables were clearly defined and well named, but before unleashing the code to production I made a copy on a floppy and removed all comments from the production version. I also used global search and replace to rename all variables to a,b,c,d,e etc... The reason I did this was I kind of resented the fact that I was doing something that I wasn't been paid anything near what I should be getting for doing it. On a flip side, they never recognised my coding skills and I left the company a few years ago for better pastures. I still have the floppy and the programs are still in use, I will gladly do contract work for them to make changes. At a contract rate, of course.

      This also has an analogy to contractors leaving time-bombs in systems to protect themselves. The practice is un-ethical, but hey - take a closer look at corporate life, what makes you think that's ethical? If you are dis-gruntled about doing coding when you are not being paid for it them it becomes very easy to justify this kind of practice. If you are being paid to do coding, then your contract should include an agreement to document your code according to a set of guidelines. Woe betide any foolish coder who uses the practices above while bound to such a contract.

    5. Re:Maybe you shouldn't be working for the place. by delld · · Score: 1

      Get paid to do this!
      The other day I saw a job description for a Java obfusticator (SP?). Finally a job for those who do not know how to program properly.

    6. Re:Maybe you shouldn't be working for the place. by Anonymous Coward · · Score: 0

      Actually, Java Obfuscation is for the paranoids who don't want people figuring out their source code by looking at the byte code. Do a search on the web, there are a lot of automated mangling tools for this purpose.

    7. Re:Maybe you shouldn't be working for the place. by jay_rf · · Score: 1

      You know this actually happened to me. When I got to a site I had to write a knee-jerk response program that was a total piece of crap. One year later - someone who is still actually using it - asks me if I can make a change to it. Man - never again. I learned my lesson well.

      I have to admit though that writing bum code for fun on a crash test dummy is a lot of fun (if you can afford the time).

      --
      " -- ow my brain hurts again -- "
    8. Re:Maybe you shouldn't be working for the place. by bornholtz · · Score: 1
      On a flip side, they never recognised my coding skills and I left the company a few years ago for better pastures.

      They never recognized your coding skills because you wouldn't let them.

      If you are dis-gruntled about doing coding when you are not being paid for it them it becomes very easy to justify this kind of practice.

      But you're still in the wrong here. Instead why didn't you create the best, most maintainable code possible and then show them. Prove you're worth the extra bucks and you'll get it. On the other hand, prove that you're a bitter script-kiddie and you'll get paid accordingly.
      --
      -- Freedom means letting other people do things you don't like.
    9. Re:Maybe you shouldn't be working for the place. by Kvort · · Score: 2

      >But you're still in the wrong here. Instead why didn't you create the
      >best, most maintainable code possible and then show them. Prove you're
      >worth the extra bucks and you'll get it. On the other hand, prove that
      >you're a bitter script-kiddie and you'll get paid accordingly.

      First, I'm not saying what he did was right.

      But, the truth is that business types will walk all over you if you let them. I got out of college, and started into the industry. I went to work for a company for a VERY low salary. I figured I would show them how good a coder I was, and they would up my salary. According to the other people who worked there, and saw/used/maintained my code, I am a pretty good coder. I was there for nine months and (finally) got a SIX PERCENT raise. The average salary where I am was almost twice what I was making.

      The business types don't really care how good you are, or how much you code, or how good your code is, they care how much you yell and scream your head off.

      >>>>>>>>>> Kvort

      --
      -Don't mind me, I'm personality-deficient and mentally-impaired.
    10. Re:Maybe you shouldn't be working for the place. by Anonymous Coward · · Score: 0

      Bingo.

      I wish more people would understand that usually programmers are NOT rewarded for their programming skills. No one gives a crap about how elegant the code is, except for other programmers. The praise and worship of your peers may satisfy lots of people out there, I guess.

      But the business people who have the bucks don't give a crap for that stuff. They only thing they care about is "does it work?" and "did you do that 6 months of work in 2 weeks like I commanded you to do, oh my unworthy slave?" That's it.

    11. Re:Maybe you shouldn't be working for the place. by bornholtz · · Score: 1
      I went to work for a company for a VERY low salary. I figured I would show them how good a coder I was, and they would up my salary.

      I did too. Then after almost two years they had the nerve to give me a 2 1/2% raise. So I did what all good programmers have the right to do. I quit!

      My next employer was very good to me (and had one of the worst reputations in the area for employee relations). In less than two years working there, I more than doubled my salary.

      I don't disagree with you that there are PHB's out there who will screw you if you give them a chance. But remember, a GOOD programmer can walk across the street and get a better job for more money with almost no effort.

      If you got screwed by your employer and you bent over and asked for more, then I have no pitty for you. There are a whole lot of great jobs out there with supportive management.

      --
      -- Freedom means letting other people do things you don't like.
    12. Re:Maybe you shouldn't be working for the place. by Kvort · · Score: 1

      Hmmm... Brought up story to make point. Didn't think anyone would be interested in my own pitiful experiences in the business world. :)

      Actually, no, I spent a year at that company, at which point in time I realized I was being royally screwed, (I realized before that actually, but was hoping they would fix it) and went to the company I am working for now. 25% raises are nice. :)

      >>>>>>>>> Kvort

      --
      -Don't mind me, I'm personality-deficient and mentally-impaired.
  6. Make Code Look Like Ascii Art by Carnage4Life · · Score: 1

    He forgot one of my personal favorites. Make the code look like it isn't code. Such as

    for(int i =0; i-->;)

    in Java, C or C++.


    Bad Command Or File Name

    1. Re:Make Code Look Like Ascii Art by Signal+11 · · Score: 1

      Cute, but if I read it correctly it'll fall through right away without executing the next line. What's the point in that?
      --

    2. Re:Make Code Look Like Ascii Art by loki7 · · Score: 2

      I don't know what you're smoking, but that doesn't just look like it isn't code: it isn't code.

      At least it's not C code.

      You can't declare variables inside of a for statement, and even if you could, I've no idea what i--> is supposed to parse as.

      /peter
      main(){main(fork());}

    3. Re:Make Code Look Like Ascii Art by Anonymous Coward · · Score: 0
      You can't declare variables inside of a for statement

      In C++ it's perfectly legal.

    4. Re:Make Code Look Like Ascii Art by wowbagger · · Score: 2

      Actually, you can define variables at the start of any scope, for example:


      if (foo)

      {

      int i = 0;



      }


      and in C++ you can define them in the for itself:


      for (int i = 0; i &lt 100; ++i)


    5. Re:Make Code Look Like Ascii Art by Anonymous Coward · · Score: 0
      Very easy to do in perl. Here is an actual snippet of code from one of my CGI scripts:

      $pat=~s/\\/\\\\/g;
      $pat=~s/\//\\\//g;
      $pat=~s/\|/\\|/g;
      $pat=~s/\s*,\s*/|/g;

      Never pass up an opportunity to backwhack away!

  7. Help! by Imperator · · Score: 1

    I tried to write unmaintainable, obfuscated code that would make be irreplaceable, but I failed. Do you think it had anything to do with my using Python? :)

    --

    Gates' Law: Every 18 months, the speed of software halves.
    1. Re:Help! by h2odragon · · Score: 1
      Unreadable Python is tough but can be done. See the standard turtle module; xmllib shows what can be accomplished through proper use of regexps.

      Many of the rules he mentions can be applied; just because your first block used one indent doesn't mean the second block (at the same level) need use the same indent. The "open list" line continuation trick can be good for some real horrors with some care.

      Of course if you're willing to work at it you can do things like this:

      from sys import*;from string \ import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!=
      '-',a);d='-d'in \ a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l -d,l-1+d
      while s:s=stdin.read(inb);s and \ map(stdout.write,map(lambda i,b=pow(reduce(
      lambda \ x,y:(x>8*i&255),range(o-1,-1,-1)))


      (\ denotes form induced breaks not present in the original; should be 4 lines total).

      Extra point if you can figure that one out and/or name the source I've shamelessly stolen it from.
  8. After A while... by PovRayMan · · Score: 1

    Checking out messy code after a few months with no documentation, I can't even understand my own damn code! That like, sucks and stuff.

    -PovRayMan

  9. For folks who complain about VB .... by Pfhreakaz0id · · Score: 4

    I Quote from the essay .... Maintenance programmers, if somebody ever consulted them, would demand ways to hide the housekeeping details so they could see the forest for the trees. They would demand all sorts of shortcuts so they would not have to type so much and so they could see more of the program at once on the screen. They would complain loudly about the myriad petty time-wasting tasks the compilers demand of them.


    This is precisely the reason VB is so popular for business apps. You have to really work hard to confuse matters sufficiently in a VB program so that a decent maintenance programmer can't figure it out.... although I could write my own list applicicable to Vb for my current project... My favorite: Make sure you have the same variable name to reference a database in several different classes in several different programs, but have it point to three different databases depending on which variable is in scope currently :)

    1. Re:For folks who complain about VB .... by pvthudson · · Score: 2
      I would have to agree, you got to be absolute braindead to write unreadable vb code. For the most part good vb coders can write some great code then performs well. The problem is everybody and their grandma can write vb, this is where vb gets its piss poor performance. I would still write C dll's for the hard core crunching.

      --


      Its karma, Kramer.

    2. Re:For folks who complain about VB .... by Anonymous Coward · · Score: 1

      You can write bad code in any language you chose. Writing Bad C/C++ code just requires a slightly higher level of education and the same level of incompetency.

    3. Re:For folks who complain about VB .... by Malcontent · · Score: 1
      I disagree.
      You can write some serious spaghetti code in VB.
      VB almost forces you to use a lot of global variables.
      OOP in vb is absolutely horrible

      The only way to write maintanable code in VB is to use some other language to write activeX controls and use VB to script them. Everytime I write in VB I feel like sticking toothpicks into my eyeballs.

      --

      War is necrophilia.

    4. Re:For folks who complain about VB .... by Anonymous Coward · · Score: 0

      Well I am an CS student and doing work practice now. When I first came to this company I had to fix some VB code made by an outside company. There was about 700+ lines of code and NO SINGLE COMMENT! At least it was VB...

    5. Re:For folks who complain about VB .... by Kiwi · · Score: 1
      I once had a gig where I had to look at 100 pages of Visual Basic code with all of 10 comments. Talk about unreadable. It is possible for beginner programmers to make VB code that is pure spagetti.

      Most of the Perl code I have seen is pretty reasonable. The only time I wrote a piece of unmaintainable Perl code was when I had a program that was initially simple and to the point. Then the PHBs wanted to change it. Again. Then again. Before I was done messing with that code, I was naming variables after girls I knew. I finally flatly told them I would not make any more changes to the code, but it was a pure mess by this time.

      - Sam

      --

      The secret to enjoying Slashdot is to realize that it should not be taken too seriously.

    6. Re:For folks who complain about VB .... by johnburton · · Score: 1

      VB code looks simple and maintainable when you're looking at small pieces of code. And indeed for very small projects it probably is easier that many other langauges, but it just doesn't seem to scale to larger projects very well. Maybe it's just that inexperienced programmers tend to use VB and are not so familier with the how to write large programs.

      --
      Sig is taking a break!
    7. Re:For folks who complain about VB .... by johnburton · · Score: 1

      The biggest problem I see with VB code is that the programmer almost never separates the application logic from the presentation code. It's too easy to create an event handler and start coding away without thinking about the abstrations you want to use. Code written by "new" visual C++ programmers often has the same problem. This isn't a problem with the language of course, mostly a case of educating the programmers.

      --
      Sig is taking a break!
    8. Re:For folks who complain about VB .... by Anonymous Coward · · Score: 0

      yes and no
      VB is great for thin layers of validation & button handling but it tends to turn into a nightmare when used to handle complex business logic. Of course that is why we have c++ activex controls.

      until the registry eats itself for the 47 millionth time of course.

    9. Re:For folks who complain about VB .... by Anonymous Coward · · Score: 0

      VB is fine for small projects, up to a couple of thousand lines. But it just lacks the scaling and maintablity to expand to full scale applications such as a hospital registration system.

    10. Re:For folks who complain about VB .... by cs668 · · Score: 1
      The problem with tools like VB, PowerBuilder is that they let people code beyond their ability.

      This lets people develop applications that are unmaintainable, because the original writer did not have the background to handle the implementation of such a complex app. But, the persons incompetence has been hidden by the development tools they are using.

      Only later do you find out they have created crap!

    11. Re:For folks who complain about VB .... by Pfhreakaz0id · · Score: 1

      I would have to agree that is possible to write BAD vb code. I just meant that it is usually possible to figure out what's going on. For the guy who said globals are almost always neccesary (sp?) in Vb, the current project doesn't have ANY. The problem isn't the encapsulation into classes. The problem is mostly naming conventions.

      Anyway, I would also agree with the comment above that it lets people without the skill start a project that quickly becomes unmaintainable. I think many of these stem from lack of DATABASE knowledge than programming. The current project could be so much improved if it had a decent backend. Instead it's in 8 Access databases with NO relationships. And some Btrieve, which isn't too bad.
      But of course, you can't change the database without starting all over. Most folks realize FAR too late that you can change the logic & the presentation forever, but changing the data structure means starting over!

    12. Re:For folks who complain about VB .... by handorf · · Score: 1

      I respectfully disagree, but only for one reason:

      VB lets managers be programmers, or at least think they are.

      I have seen WAY too much VB code written by somebody who wouldn't know a formal design if it was used to build the machine that ripped them limb from limb as they scream appoligies for all the horrible code they've written.

      At least with C/C++ there's a cost of admission built into the language. This doesn't mean that there aren't bad C programmers, but, IMHO, seeing code my ex-manager wrote in VB because he THOUGHT he knew what he was doing (It's so easy, even I can do it) makes me want to give into the red rage.

      Don't get me wrong, a good VB programmer is a wonderful thing, but difficult to find in the forest of horrible ones.
      -- I'm omnipotent, I just don't care.

      --
      -- IANAEG - I am not an elder god.
  10. Maintainable Code by Anonymous Coward · · Score: 4
    To write unmaintainable code is a very unworthwhile thing to do, because you will be essentially married to the code until you find somebody to which you can explain it.

    Personally once I write some code I want it to be maintainable enough so other people can contibute for I can move on with other things. I do not feel that my life consists of solely maintaining code, why not do something challenging? Rather then babysitting one of my past accomplishments. Why not take over the world?

    1. Re:Maintainable Code by pvthudson · · Score: 1
      Well if you are developing for an Open Source project then your code must be readable, but when you develop for a one time shot product and you hate the PM, then coders tend to stray off, just for spite.

      --


      Its karma, Kramer.

    2. Re:Maintainable Code by Vrallis · · Score: 1

      I'm in charge of a rather large communications system (between a central office, several warehouses, and a few hundred stores). We are now in the process of porting everything, lot stock & barrel, to new hardware and new OS (SCO 5).

      A) The *original* system was done on a UNISYS mainframe. Hence the initial style of this pile of rubbish.

      B) Half the system is in a 4GL language, written by programmers that were learning the language for the first time.

      C) Half the system was written in shell scripts. They were originally plain bourne shell (yuck), and some kind soul decided to convert them all to Korn. Unfortunately, that consisted mainly of changing the #! line. Utterly worthless.

      D) Raw SQL is sprawled all throughout this stuff. The statements for executing each of these SQL scripts varries in ways you can't imagine.

      E) Three-quarters of this code is on 13 different HP-UX boxes. Very old HP boxes.

      F) The rest is on old SCO 3.x/4.x boxes, which were never properly installed to begin with (they core dump every time you try to shutdown the system). There is no way in hell I'm ever trying to re-install them. Never.

      G) The entire system consists of about 500 shell scripts, 70 or so 4GL programs, and several hundred SQL scripts -- many of which are dynamically modified and executed by said shell/4GL programs.

      H) I'm only about the fifth person to be put in charge of this code since it was written. Nobody with any experience in it works here any longer.

      I think I'm going to learn to tie a noose this week =)

    3. Re:Maintainable Code by Rambo · · Score: 1

      Welcome to hell ;-) I work in a similar situation where I'm required to debug and maintain "applications" that use shell scripts (bourne) like they were free money. It's always invigorating to follow a shell script that chains through five other scripts, via rshell, to three other systems before completing its miracle mile back where it started. Makes it really interesting, especially since a lot of information is hard coded in (like hostnames), and if one script bombs, you never know which one it is. Another nifty trick I've seen here is to cut and paste your way to glory by copying the same cryptic routine over and over again with small variations on a theme.

      And finally, don't forget to make it IMPOSSIBLE to call the scripts by hand, something in the style of:
      myscript BIG_RANDOM_NUMBER PI_TO_100_DIGITS MY_LIFE_STORY BILL_CLINTONS_FAVORITE_RESTAURANT.

  11. Fit all code on *one* page. by torpor · · Score: 4

    Back in the good old days of DOS (and thus, 80x25 page size), I had a programmer in my team who followed the "all functions must fit on one page" rule...

    Man, the number of times I wanted to kill that guy. We called him Anti-Whitespace.

    Scarey though, how that page gave guidelines that I myself have been guilty of following too many times in the past. Is there a counter-page to that one, that gives guidelines (general purpose) that make it easier to work with other programmers?

    --
    ; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
    1. Re:Fit all code on *one* page. by Imperator · · Score: 2
      Is there a counter-page to that one, that gives guidelines (general purpose) that make it easier to work with other programmers?

      Unless I'm very mistaken, that's a Johnny Don't list. As in, "Don't do what Johnny Don't does". (Non-native English readers: "&$thing unless $johnny_dont->can($thing);".) If you don't do the things on the list, you won't have unreadable code.

      --

      Gates' Law: Every 18 months, the speed of software halves.
    2. Re:Fit all code on *one* page. by adamv · · Score: 1

      Hmmm... I definately wouldn't sacrifice whitespace to make a function fit on one page. But I am a fan of making object's methods fit on a screen or 2 (well, at high res at least) and never having an if's else more than a screen away if at all possible.

    3. Re:Fit all code on *one* page. by Raul+Acevedo · · Score: 2

      That "rule" is actually a good one. Except it should be more of a guideline, than a strict rule. The idea is a good one, which is to keep code in logical, relatively small and coherent modules. Going overboard to forcing it to exactly 25 lines (or any exact number), for all code, is bad.
      ----------

      --
      In a real emergency, we would have all fled in terror, and you would not have been notified.
    4. Re:Fit all code on *one* page. by mmmmbeer · · Score: 1

      Whole function on one page!? Hell, I have functions whose calls don't even fit on one page.

      Sadly true...

    5. Re:Fit all code on *one* page. by hypatia · · Score: 1

      Except it should be more of a guideline, than a strict rule.

      :)
      Shouldn't everything?

      Anyone blindly adhering to a rule like that must have forgotten the meaning.

      The spirit of the rule is to have understandable maintainable code - the function should be small enough to twist your mind around without getting sucked into a mental whirlpool of pointers to pointers to..., and besides you don't wnat to have to scroll too much :)

      Obeying the letter of style rules is counter-productive - it shows a lack of understanding of the spirit.

    6. Re:Fit all code on *one* page. by F2F · · Score: 1

      sheesh... what language did you write that in? Is it perl? You Obfuscator! Perl should be used only when you need something accomplished (and when you are sure no one else will ever look at it)...

      Here is your masterpiece in C:

      if (!johnny->can(thing())
      thing();

      Or if you necessarily need to obfuscate a bit:
      johnny->can(thing()) ? not_thing() : thing();

      There.. clean as a newborn baby :)
      And I betcha it's a bit faster... ;)


      Flame On!

    7. Re:Fit all code on *one* page. by Anonymous Coward · · Score: 2

      The great artists know every rule they are breaking and can explain what they hoped to accomplish by breaking a rule.

    8. Re:Fit all code on *one* page. by toriver · · Score: 1
      Back in the good old days of DOS (and thus, 80x25 page size), I had a programmer in my team who followed the "all functions must fit on one page" rule...

      80x25? Luxury! I remember back in the heydays of home computers (early 80s), where all those Commodore and other machines came with a MBasic subset that allowed up to two 40-character lines to be "parsed" as a program line. For simplicity, they also let you use "?" as a shortcut for "PRINT" - this meant that if you wrote a program line of 80 characters with that shortcut, you couldn't later edit it... :-)

    9. Re:Fit all code on *one* page. by Anonymous Coward · · Score: 0
      Whole function on one page!? Hell, I have functions whose calls don't even fit on one page.

      This symtom usually means that you could have abstracted your code better, by using an object holding all the arguments. The minimum benefit is that you can write wrappers around one function more easily (without bothering enumerating all the variables). Often, it semantically makes sense to regroup the variables (for instance "char* data, int dataSize" should be factored into "struct { char* data, int size } Block;"), so you generally get other benefits.

    10. Re:Fit all code on *one* page. by Anonymous Coward · · Score: 0

      I can see having any given function fit a single page,
      but with whitespace.

      Programming in Forth, using 1K blocks per
      screen, the general rule is "If it doesn't fit
      on one block, it's probably time to rethink and
      refactor the thing."

      As for making it unmaintanable, eh, that's all too easy. But if you really want to send someone on a helltrip you could try recursive vectored execution.

    11. Re:Fit all code on *one* page. by GomerDomer · · Score: 1

      In the years of programming, I came upon one way to make "if"s of more than one line a little easier to work:

      I write the initial "if" statement, duplicate it, and then (in C) insert a "} // " in front of the duplicate "if". This way if you are scolling through the code, you know what the ending "}" is for (also helps in tracking down the extra bracket).

      I actually spent 11 years at one company before moving on, and often I had to debug code I wrote 5 to 10 years before. I made sure I documented it well if I could not easily remember what I coded years before and had to figure it out.

      The most important thing to remember about documentation is that you may have to go into the code you wrote after someone else has come in and mangled it. I was often ridiculed by contractees for making a point of always initializing variables and making sure that deallocated pointers were set to NULL (had a macro that freed and set to NULL), but after spending haurs and days tracking down bugs that other programmers put in by adding their own bad code, I found it worth while.

    12. Re:Fit all code on *one* page. by Anonymous Coward · · Score: 0
      You guys are soooooo off track. It's easy to fit entire functions a a sheet of paper. Just use APL! And you can't beat APL for job security!

      Note: This post contains 99.44% of the USDA recommended daily requirement of sarcasm.

    13. Re:Fit all code on *one* page. by Anonymous Coward · · Score: 0

      I was taught this, too, by an old, crusty CS professor. But I've realized that the idea isn't to cram all of your function code onto one page, but rather to be able to express the idea in a page. If you can't accomplish the task within 60 lines, it's a good idea to rethink your algorithm... not eliminate all whitespaces.

    14. Re:Fit all code on *one* page. by mmmmbeer · · Score: 1

      Well thank you so much for jumping to stupid conclusions and making all kinds of foolish assumptions about my code. Unfortunately, you're completely wrong. I know all about abstracting code. I won't go into the details of why these functions require so many parameters, because that in itself involves trade secrets. I will say, however, that every one of the parameters is necessary, and these functions cannot be broken down. Furthermore, even if I wanted to create a struct, I can't because I'm writing in Javascript!

      Next time, keep your pathetic judgements to yourself, coward.

    15. Re:Fit all code on *one* page. by MotoMannequin · · Score: 1

      Would Picasso every try to fit one of his paintings on more than one canvas?

      --
      MotoMannequin
      "With all appliances, and means to boot!" - William Shakespeare
    16. Re:Fit all code on *one* page. by Anonymous Coward · · Score: 0
      >Back in the good old days of DOS (and thus, 80x25 page size), I had a
      > programmer in my team who followed the "all functions must fit on one page" rule...

      It must have been one of those old implementations of FORTH which used "screens"...

      Ah... Forth... Such a nice obfuscatable language... Yet, so powerful. I remember cramming 10,000 2-decimal numbers tables, WITH the application, in only 4096 bytes of storage...
      Unfortunately, it didn't last long, because the boss was so paranoid and could not understand FORTH, and he was so afraid that we'd take him for a ride...

  12. Open Source ugly code? by MicroBerto · · Score: 0

    What about writing ugly code for an open source project? We are supposed to be supporting open source, and in the meantime this fool wants people to make code unreadable. The two won't go together, because if we want it to work WELL, we must comment it well, and not play tricks! Yea yea yea, i understand the job security stuff, and there are better ways to make yourself in demand. I'll take the article with only humor, but in no way would i take it seriously.

    --
    Berto
    1. Re:Open Source ugly code? by Enmity_qXp · · Score: 1

      You ever had a dog that likes to steal food off your plate? A good way to make him stop is poor some hot sauce all over some food, leave were he can get to it, and leave the room for a while. when you come back, the dog will be quite unhappy.

      if you let someone get burned by their own bad habits, it is sometimes enough to break them of those habits.

      the article is a bit sarcastic.... at least thats how i read it.


      --
      "there's a big difference between kneeling down, and bending over" - FZ
    2. Re:Open Source ugly code? by pedro · · Score: 1

      DANGER! RANT ALERT!
      Perhaps I don't get the GNU paradigm right, but I find VAST amounts of open source code woefully underdocumented. In fact, MOST of it!
      Some sort of map to the source should be provided as a matter of course; recursive makes should be avoided; Changelogs should actually LOG CHANGES; and in a manner that folks not intimately involved w/the project can understand!
      Linux kernel is a prime example. I'm running 2.2.13. Works great. Nowhere in the docs are the enhancements over 2.0.0 explained in a coherent manner. Or the enhancements over the 1.2.13 I started with. The comments in the code are so 'cliquey' when they exist that I have no idea where I am w/out grepping my brains out and flicking betwixt a bazillion xterms.
      This is not good, even as intellectual excercise This bespeaks a cavalier disregard for the audience. We are not cliques *here*, despite how usenet may make things look.
      The clearer we can explain to each other, the less of what I now realise to be cheap one-upsmanship will present itself in the open source arena. I see people staking out ground in this new world, and I don't like it. I see priesthoods developing. Perl people with cryptic .sigs giggling to themselves about how clever they are ( like the fairly (?) clueful but ultimately useless perl group denizen abigail -- you're killfiled, girl! all criticism, no content! RTFM - on Humanity! Anyone who reads perl or html groups will know the bitter wannabe abigail. DAMN! that felt good! WHO'S WITH ME?)
      We need to get the actual developers involved in the LDP and carry their weight THERE to make this thing work. It's all very sexy to create code and have the world lavish praise upon you, but have the courtesy to document what you do so so you don't need a sycophant class to follow you around scribing down everything you say. Apparently that's where the LDP is right now; shoveling up the spoor of our heroes so as to serve up a feeble portion of their vast 'knowledge' to the groveling masses.
      I don't think this is actual intent, but the evidence indicates otherwise, at least to me...


      --
      Brak: What's THAT?
      Thundercleese: A light switch.. of TOTAL DEVASTATION!
    3. Re:Open Source ugly code? by Anonymous Coward · · Score: 0

      Now that you have spotted a problem in the source code you are required to fix that problem.

      Actually I find the site http://lxr.linux.no/ to be invaluable in browsing the Linux kernel code.

      It is a hyper text cgi code browser. You can take the code and modify it to work with your own code trees. I modified it to work with CVS and .sc files without too much effort.

      It helped me understand a nighmare code project at work in about half the normal time that other people required. Made me look really good. I released it to the rest of the team once I gotten a good headstart over them.

      he he he

    4. Re:Open Source ugly code? by pedro · · Score: 1

      Excellent! Thank you!
      This will help. A lot.

      --
      Brak: What's THAT?
      Thundercleese: A light switch.. of TOTAL DEVASTATION!
    5. Re:Open Source ugly code? by pedro · · Score: 1

      I really should have said much more in my original post.
      I'm pretty good at spotting bad code and improving it. The slashdot source, for example, that I've seen so far contains tons of unhandled error situations, call overhead, etc, etc, etc.
      I was originally thinking of my experiences in the mid 80's porting game code, some of it written in (ack!) basic. The offending author steadfastly refused to document anything he did. He wrote code thet was compiled using a p-code c64 compiler (blitz) and I was expected to move it over to a native code compiler on the apple (einstein).
      P-code is compact. Native is large. Get the picture?
      What would *you* do?
      I fired up Glen Bredon's Sourceror and disassembled the blitz runtime library and massaged it to run on the apple.
      It all worked, in the end. his code ran on the apple, unmodified.
      Never published, though. Game was ultimately lame.
      Sigh...

      --
      Brak: What's THAT?
      Thundercleese: A light switch.. of TOTAL DEVASTATION!
  13. As an architect by twit · · Score: 3

    I hate it when members of my team write unmaintainable code. Frequently, when time's short or when people need help, I have to dive in, and I've found it difficult to get my bearings in code that I did the initial design for - difficult to see the forest for the trees, even when I planned out the forest.

    Good practises in programming isn't just for academics; it's the epitome of professional code writing. A manager once tried to draw the definition of a hack and a real programmer by the completeness and bug-free state of their code. I think he's wrong. I think that a real hack writes code that no one can pick up. A real programmer writes code that anyone can pick up and fix or expand - whether it's complete at any one point or not.

    --

    --

    --
    There is no premature anti-fascism. -Ernest Hemingway
    1. Re:As an architect by Anonymous Coward · · Score: 0

      you are exactly right. One good thing about OSS is that it makes writing sloppy code potentially embarrassing. I treat code like I treat a paper I write -- somebody has to read it, I want it to reflect all of the thought that I put into it.

    2. Re:As an architect by Anonymous Coward · · Score: 0

      Good coding style often confuses the uninitiated. Face it when we weave an elegant family of classes to describe business logic we the architects often confuse the hell out of the JR programmers. Unless our grand layout is well abstracted and compartmentalized we often end up doing part of the code ourselves. Seems to me there was an article by Andrew Koenig on the matter of abstraction and how beneficial it may be. just my .02 cents

    3. Re:As an architect by pspeed · · Score: 1

      Three words:
      Frequent code reviews.

      After getting picked on regularly most "hacks" will shape up or ship out.

      When hiring new people, ask to see a sample of their code. Discuss it with them to make sure they really wrote it. (Usually just asking them why they did something in the code is enough.) If it looks like crap then you know what you are getting into. If it's beautiful then you know they have the potential... and frequent code reviews will keep them on their toes.

      --
      Edu. sig-line: Choose rhymes with lose. Chose rhymes with goes. Loose rhymes with goose.
      Comparing? THEN use THAN.
  14. 54 tips? by prok · · Score: 1

    All you gotta do is write it in perl...

    1. Re:54 tips? by sterno · · Score: 2
      Ah yes, how to make prefectly usable code look like line noise in one easy to use language :)

      ---

      --
      This sig has been temporarily disconnected or is no longer in service
    2. Re:54 tips? by pb · · Score: 1

      Why waste time when you can use a language where line noise is practically the native syntax?

      Write in APL. (Sounds Greek to me...)
      ---
      pb Reply rather than vaguely moderate me.

      --
      pb Reply or e-mail; don't vaguely moderate.
    3. Re:54 tips? by dimator · · Score: 1

      Couldn't agree more. Now, I expect a million and a half replies saying "bad PROGRAMMERS write bad code" Yes, I agree with you there, but perl makes it easier for even GOOD programmers to write sloppy unintelligble code, and for BAD programmers to write line noise.

      The perl community (Larry Wall too, if I'm not mistaken) often touts "There's more than one way to do it!" with perl. Well, is that necessarily a good thing? That translates, in my mind, to "There's no discernable syntax you have to follow!" This makes it an almost write-only language.

      Personally, I keep my perl code looking as much like C code as I can. That means no fancy-shmancy 12 function, one liners. If I have to press shift + a number more than twice in one line of code, it's a bad line of code! I think there is somewhat of a status symbol that goes along with writing convoluted perl code in this fashion, which is nightmare for the code maintainer.






      -----------------
      Your attention please everyone, if I could just say a few words... I would be a better public speaker.

      --
      python -c "x='python -c %sx=%s; print x%%(chr(34),repr(x),chr(34))%s'; print x%(chr(34),repr(x),chr(34))"
    4. Re:54 tips? by double_h · · Score: 1

      Yes, I agree with you there, but perl makes it easier for even GOOD programmers to write sloppy unintelligble code, and for BAD programmers to write line noise.

      I won't argue that there's some nasty-looking Perl code out there, but I also think that if used intelligently, Perl can make it easy to write very concise, intelligible code. For instance, the awk-like regular expression operators are often accused of looking like line noise. But to my eyes, once you learn the syntax (which any Unix person should mostly know to start with), it's a *lot* easier than doing the same thing in C. Likewise, all the modules available from CPAN make it easy to do all *sorts* of things using consistent, widely-used methods, rather than having to roll your own every time.

      Personally, I keep my perl code looking as much like C code as I can. That means no fancy-shmancy 12 function, one liners. If I have to press shift + a number more than twice in one line of code, it's a bad line of code

      I strongly agree with your rule about making Perl code look as much like C as possible - I am very anal about indentation, spacing and soforth. But your second rule strikes me as rather impractical -- after all, it would mean that:

      if ($foo eq $bar) {

      is already in violation, with a whopping four shift+number characters...

      (While I'm at it, I'll add a perfunctory bitch for Malda to allow use of the html pre tag so people could post actual code fragments in discussions like these...)

    5. Re:54 tips? by Abigail-II · · Score: 1
      If I have to press shift + a number more than twice in one line of code, it's a bad line of code!

      I guess your C code either has lots of lines of bad code, or rather unusual formatting. After all, the use of parenthesis is quite common in C. And on most keyboards, that's shift+9 and shift+0. && would be out as well, and a single *p fills up the quota of shift+number characters before it turns into a "bad line of code".

      Good thing you use Perl. You can omit parens in many function calls.

      Let's just assume you are trolling.

      -- Abigail

  15. buggy code by Anonymous Coward · · Score: 0

    Good programming practices were invented to help _you_ the programmer produce bug free code. Perhaps this guy was a member of the Windows development team? (Sorry couldn't resist :-) Windows is crashing gotta go...

  16. For those who are interested by tilly · · Score: 2

    The stuff at the end about coding environments is very similar to what I have heard Smalltalkers describe as how a good Smalltalk environment works.

    And of course anyone who wants to avoid accidentally using a few of those practices could be worse advised than to buy, read, and apply the concepts in a copy of Code Complete...

    Cheers,
    Ben

    --
    My usual seat in the cluetrain is at A HREF="http://pub4.ezboard.com/biwethey.ht
  17. Removing toungue from cheek... by eldurbarn · · Score: 5
    The first n years of my career were spent maintaining old code. Assembler. I vowed "I will write maintainable code".

    Now I write good code. Maintainable. Well commented. Meaningful variable names. Nothing fancy. I know what it's like to revisit my code ten years later.

    There is a problem, though.

    Nobody else seems able to maintain my code. They just can't understand it.

    Despite high-level pseudo-code algorithm descriptions, threaded comments, good up to date written documentation, they just can't wrap their tiny little heads around how I do things.

    I can go back to something I wrote 15 years ago and fix problems without generating new ones. My code is robust enought that I can shovel out a few thousand lines and jam in another 10,000 lines, test it for a day or two and release it... and get no bug reports for another 5 years. I consider this to be maintainable code!

    Go ahead... break all the rules suggested in the article. You may still produce code that other, lesser programmers simply can't cope with. The code is an expression from the mind of the person who wrote it... and sometimes writing to the lowest common denominator simply isn't possible.

    And then they blame you for writing unmaintainable code.

    --
    -Eldurbarn
    1. Re:Removing toungue from cheek... by sterwill · · Score: 1

      Wow! You are the perfect programmer. Surely I can download and read some of this fault-free code! Joy of joys, tonight I have a new idol! URLs, please.

      --

    2. Re:Removing toungue from cheek... by Anonymous Coward · · Score: 5

      Oh dear, oh dear ...

      My company (owned by me) started a small contract last month at "a small financial services company" (let's not be too specific). About two years ago, they started to migrate off of DOS, a small 3090, and some netware boxes to Solaris. In the meantime, their workload has been growing. The old mainframers decided that they didn't like UNIX and waged a two year war to get rid of UNIX. All the UNIX guys left. Then they bought out two larger (but apparently worse-run) companies that were run completely on, you guessed it, UNIX. The mainframers announced that they were old and tired and perhaps they should bring the UNIX guys back (they were apparently told that they didn't have a choice). But they wouldn't come back (lots of work in Dallas for good UNIX guys, without rabid mainframers in the next cube). For the last nine months or so, they have had one group of "Unix" "consultants" from most of the majors over there "trying to fix the code" that they inherited. The code? perl. Just perl. A little ksh junk, some C, mostly perl.

      I (and two other people) are now 10% done (we estimate, and we are usually right on estimates). None of us can figure out what was so hard about the code. Really. Some of these "consultants" had teams of 20+ people here. I think that they must never have seen UNIX before in a production environment.

      This industry is very, very full of the clueless, and not all of them are running NT (most, yes, but not all). When people keep talking about the coming IT salary shakeout, I think of situations like this, and lots of others, just from the last few years. Good people will always be in demand. The lusers will rapidly find it hard to pay their bills. And this is not new -- it is just filtering from the most structured areas (that would have been MVS/COBOL shops) to the least structured (just wait, web-designer weenies -- your time will come), and it is hitting UNIX now. I think that the excuse of "this is just wild and crazy code and I no mortal man could wade through this spagetti" will soon hold as much water as "it's the compiler -- it hates me!" Heh. With this company, they were not clueless -- they kept the 3090 and never ever seriously considered NT. But UNIX was still believed to be bad juju and scary, so they accepted the explanations. I suspect that they won't in the future, as we are not missing chance to point out how clear things really are.

      And, as an aside, not a single one of the COBOL guys that I knew (actually, a lot of them were and are women) were never out of work more than a few weeks, and some of them have been keying for dollars since before I was born (1970, folks). Their only recent job changes have been to jobs paying $200+ an hour.

      Personally, I cannot fscking wait until some of these Thai-stick Bogarting full-of-BS tool-dependant Shockwave-inflicting pretentious "artist" wannabes that make web front ends to business site such a holy terror to implement for those of us with actual skills (like perl and DB2) start being forced on pain of no work and subsequent drug withdrawl to fscking write fscking proper fscking HT-fscking-ML to the fscking spec the client fscking asked for. Without the little moving GIFs. Grrrrrr ...

    3. Re:Removing toungue from cheek... by Anonymous Coward · · Score: 1

      My point, which I see that I was making only by implication, rereading this now after coffee, was that I think that the original poster was not in fact an arrogant twit, but that he (she?) was coding to a higher standard. Which is fine, as people should be smart enough to do the job given copious clues (which this person appears to leave). If they cannot, they need to look into other lines of work requiring less thinking. If you have to write code for idiots, you will be spending way, way, way too much time on attempting to resolve error conditions between the ears of the potential coder, which is stupid. They are supposed to be able to code, right? I like (and insist on) comments. But they are supposed to illuminate the intent behind the code. YOU ARE ALSO SUPPOSED TO BE ABLE TO READ AND WRITE THE CODE. If that is too tough (and you refuse to accept the challenge to learn how to write better code), then perhaps a job somewhere else would be good. Soon. Now.

    4. Re:Removing toungue from cheek... by double_h · · Score: 1

      Personally, I cannot fscking wait until some of these Thai-stick Bogarting full-of-BS tool-dependant Shockwave-inflicting pretentious "artist" wannabes that make web front ends to business site such a holy terror to implement for those of us with actual skills (like perl and DB2) start being forced on pain of no work and subsequent drug withdrawl to fscking write fscking proper fscking HT-fscking-ML to the fscking spec the client fscking asked for. Without the little moving GIFs. Grrrrrr...

      Okay, you have by a large a good rant going here, but I have to take exception with this point, on the grounds that 98% of the rampant pot smokers I have encountered in the IT community are very competent coders, Unix admins, and network guys. In other words, the kinds of people who suffer most from dealing from the multimedia web-gadget lightweights who, from my experience, are mostly white-wine drinking thirtysomethings with a marketing or PR background.

      And to be fair, I have to raise an eyebrow after seeing your post lambast the incompetence of consultants who use "perl. Just perl", and then later offer a definition of "actual skills" as Perl and DB2. Hmm.

      But don't get me wrong, we are definitely in agreement that all those Shockwave-fetishing Front-Page using (cough cough) "developers" ought to have their fingers smashed with hammers.

    5. Re:Removing toungue from cheek... by Anonymous Coward · · Score: 1

      No, perl and DB2 aren't "skills" the way microcontroller code is a skill, and I wasn't comparing myself to people like that. I am not a guru, nor was I claiming to be. That was sort of my point. I am a liberal arts major who discovered that he liked UNIX in college. I am sure that I would have benefited from some CS classes, but everything I know is OJT-based. So, given that I, just like the two perl monkeys who I am paying quite a bit just to do perl and have probably forgotten more than I will ever know, have no problem with the code (and am filling in until someone gets back from a vacation, which I require that my employees take), I should think that people who were paid to be perl experts shouldn't have had problems either.

      Also, the "consultants" didn't write the perl (I may not have been as clear as I could have been -- it was late). The previous admins at both companies had done it all. As the two companies had sought to cut costs, they had laid off essentially everyone in systems, so that by the time they were acquired, the code had been sitting for close to a year. And then most of the second year passed. And it was all still running perfectly well. This was validation and checking code, credit review rules, and so on. All good hacks and relatively clear if a)perl is not foreign, b)banking/compliance/credit/etc. software and policies aren't foreign. So that was where I was puzzled. I am not going to go up to Larry Wall any time soon and say "Larry, let me show you how it's *really* done." This isn't hard for me (a non-guru with a user's familiarity with perl, almost entirely making databases and userland apps play nice and doing basic sysadmin work in larger environments). Why was it hard for these very high-dollar "consultants"?

      And while I don't have time to defend DB2, it is still kind of nice and getting nicer. It has gotten a lot better than it used to be, and the Linux port is a full-featured version. I guess it depends on where you come from. For me, DB2 is worth the trouble because it is damnd hard to kill. Oracle falls over pretty easily, DB2 just slows down. I like that; I dislike emergencies. Yes, I would love CICS for Linux, and I already have ISPF for Linux and like it. Yes, I wear a tie every day, I can't help it. I was probably born 30 years to late.

      And on the pot issue, I am well aware of the habits of my peers. I liked the fact that no matter what anti-depressant that I was on (when I was trying to find a combo that worked for me), if I ran out I could always borrow some from somebody else on the floor. I like working around people who understand pain -- it makes you cautious. How they choose to deal with it is up to them. I was talking less about the Runt Rage lusers (who also love PowerPointyHair) than the people who think that they are tortured artists who wish to break new artistic ground every time they are asked to do anything on-line, like a benefits page for HR. I am sorry, but that ain't the job. And I am not (as they are quick to suggest) arguing against "art" -- just moving flourescent swirling images and HR Geiger monsters and color combinations seemingly designed to increase Tylenol sales ON A FSCKING HR BENEFITS PAGE!!!! I have had enough of these people. Who are invariably stoned. So perhaps I should have harped on their immaturity and fundamantal ignorance of layout rather than their weed use. Point taken.

    6. Re:Removing toungue from cheek... by Abigail-II · · Score: 1
      I can go back to something I wrote 15 years ago and fix problems without generating new ones. My code is robust enought that I can shovel out a few thousand lines and jam in another 10,000 lines, test it for a day or two and release it... and get no bug reports for another 5 years. I consider this to be maintainable code!

      Yeah, I used to do that as well. Untill I realized that "no bug reports for another 5 years" meant that noone was using my programs.

      (Why does an obvious troll get 5 moderation points?)

      -- Abigail

  18. ... by Signal+11 · · Score: 1

    Bah, I can tell you to do it much easier than that - use BASIC. >:)
    --

  19. What? No M$ comments? by Zagato-sama · · Score: 1

    Only one Microsoft joke so far? :) ouch, slashdot is slipping

    1. Re:What? No M$ comments? by Anonymous Coward · · Score: 0

      Or growing up.

    2. Re:What? No M$ comments? by ywwg · · Score: 1

      That's because we have none of their awful code to look at!

    3. Re:What? No M$ comments? by mmmmbeer · · Score: 1

      Of course not. We all know that M$ already knows all about writing bad code.

  20. senseless! by rahuljain · · Score: 1

    What sense does that make? If a company wanted to fire an individual he probably sucked anyway! I mean, the market is flooded so much that there are currently more jobs than people around to fill them. So, if you are being fired - then you truly ARE a dumbass. Furthermore, imagine u got promoted (it happens), and then you had to deal with someone who fuq'd with their code so that no one can do anything with it. You would be screwed years of work and money. I dunno, jus way i feel. Ill stop now.

  21. You need a guide? by Anonymous Coward · · Score: 0

    If I don't read my code for three days I get completely LOST. I'd have to either reread the whole thing (boRING!) or rewrite the whole sucker. I ABSOLUTELY cannot read other peoples code, I just don't understand what they're getting at. Who needs tips.

    1. Re:You need a guide? by Anonymous Coward · · Score: 1

      You haven't been doing this very long, have you?

      I was like you too, grasshopper, when I was but a lad. Then I got a girlfriend and was getting laid on a regular basis AND wrote about 10,000 lines of code for a very large project (the internship from hell that turned into the job from hell). By the end of that, with my smaller head screaming at me a lot less and my larger head one with K & R C, I could look at anyone's code and figure out what they were doing. Why they were doing it was another issue and *that* is why you comment, so that people know why you were doing something.

      Don't worry -- it will come. And speaking of comming, look into the girlfriend deal (try music chicks -- they understand/appreciate/suffer from obsession the same way) -- it makes it easy to focus once you have several pounds of testosterone out of your system. Wimmins is nice, albeit difficult, but they are often worth the trouble.

    2. Re:You need a guide? by Anonymous Coward · · Score: 1

      _Study_ the following three books:

      K&R The C Programming Language
      Plauger The Standard C Library
      Stevens Unix Network Programming

      Type in every example from the first and third books. Using the second book, write an example program that illustrates each of the Standard C Functions.

      Those who don't understand the Standard C library are doomed to reimplement it...

  22. Just write everything in perl >>>>>>>>>>>>>:P by TummyX · · Score: 0

    :P

  23. The REASON we want good code... by UnknownSoldier · · Score: 3

    It's not a philosohpical issue, it's one of practicality:

    When (not if) you end up maintaining someone else's code, if the code has been written in a clean way, it can be a sure joy to work with. If not, you'll be cursing that programmer for eons.
    (Lets keep Microsoft's API out of this ok ;-)


    The REASON we want good clean code is so that _we CAN_ maintain it.


    I have been in the position of looking at my own code 6 months, later, and gone "WTF?", and wasted lots of time trying to figure out just what the heck I did.

    If I had just spent the extra time to begin with, later on I could of been more productive instead of wasting time re-engineering the damn thing.

    Pay the piper up front and save time later, or be a "saving time" grinch, and find an expensive time bill later. Seems pretty obvious what "The Right Thing" to do is ;-)

    Work smarter, not harder =P

    Cheers


    BTW, Steve McConnel has a great book: Code Complete.

    1. Re:The REASON we want good code... by Skim123 · · Score: 1
      The REASON we want good clean code is so that _we CAN_ maintain it.

      I agree wholeheartedly. When I went on my first co-op (my first real-world computer-related job), I was very surprised by the amount of terrible code. At the time I was working on creating data-driven intranets. There is nothing harder than trying to expand a database application that has a terrible database design. I am a strong believer that each extra minute spent writing more legible, better-written code, is ten minutes saved down the road.

      It's not a philosohpical issue, it's one of practicality.

      While it is practical to perform such good code writing techniques, is there also not some philosophical reason as well? For example, if you had to write a program that you were 100% guaranteed would not be worked on in the future, would not need to be updated or maintained, would you write crappy code? Maybe it's a little too late, and I'm a little too tired, but it seems to me that writing good code is something we should strive for not just for practicality, but for higher reasons too. I hate to make it sound like good code is more moral...

      Hmmm, if you think of a program as a creation of yours, as something you made, then it behooves you to take the time to make it great. Ugh. Sorry, I am sure this is making no sense. Too late. Good night. :)

      --

      I could not justify my existence if I were a turkey farmer. Would I terminate myself? Undoubtably, yes.

    2. Re:The REASON we want good code... by Afrosheen · · Score: 1

      Try telling that to the moronic middle management that wanted the project finished yesterday and fails to understand the simple concept of 'a stitch in time saves nine'.

    3. Re:The REASON we want good code... by Pentagram · · Score: 1

      No, I agree. You are never sure that a program won't need to updated.

      Anyway, compare it to other professions -- eg, carpentry. You don't just knock nails into the bits that don't show. Well, good carpenters don't, anyway. If nothing else, it's a matter of pride.

    4. Re:The REASON we want good code... by UnknownSoldier · · Score: 1

      I dealt with this problem on my last job.

      When the [boss] asks you "How long will it take to get this project finished", factor in the time to write the code properly.

      You're the person doing the job, and if you won't take a stand, who else will?

  24. slashdotted by Anonymous Coward · · Score: 0

    The site appears to be slashdotted. If possible, can someone mirror it?

    1. Re:slashdotted by abischof · · Score: 1
      Ditto that... It's full :(. Ironically, I'd consider mirroring it myself, but I can't get in ;).

      Alex Bischoff
      ---

      --

      Alex Bischoff
      HTML/CSS coder for hire

  25. How to fail at software development by copito · · Score: 2

    Byte had a feature entitled: "How to Fail at Software Development, Don't Communicate" it at a slightly higher level, but is just as useful.
    --

    --
    "L'IT c'est moi!"
  26. I didn't read the whole list (i don't like horror) by toast0 · · Score: 1

    why not write the code in perl such that when the program starts it reads the code in and then executes from refrence to subs?


    (i've actually done that, and i understand what i do in my own code, but i'd like to see somebody else try to explain it :)


    i seriously hope this page was intended as a joke

  27. Bad takes more time to write by tilly · · Score: 2

    That is right. If you set out to do it in a sane way from the beginning you will very likely get the same task done more quickly than if you just hack out something on the fly and try to make it work. The maintainability and lower bug rate is a bonus on top of that.

    Cheers,
    Ben

    --
    My usual seat in the cluetrain is at A HREF="http://pub4.ezboard.com/biwethey.ht
  28. War story by eldurbarn · · Score: 3
    We had a system with about 750,000 lines of assembler, doing some heavy-duty, real-time math modeling of oceans. The hardware was old. The contractor said they'd deliver a modern system with the code in C.

    They wrote a converter that digested the assembler and produced C code... about 4 lines of C for each line of assembler code.

    So a math calculation that could easily be written in 1 line of C took 30 or 40 lines of assembler which converted into 120+ lines of C. (Stop screaming!)

    Their converter did not put the original source line as a comment in the new source. (Now you may scream!)

    Now I gotta maintain this pile of compost. I'm looking for another job.

    --
    -Eldurbarn
    1. Re:War story by Anonymous Coward · · Score: 0

      Don't know whether you'd think mine is better or worse. My employer has a large collection of programs that do office records, billing ect for small medical and dental offices - written in CBasic - in 1980. They run it through this thing called MB86 that takes a mish-mash of true Basic, snippets of C and wierd directives of its own - and spits out horrendous hungarianified C code. I must admit, I've seen some very good clean code in basic, but those snippets are few and far between. I gives me pains sometimes as I am adding code (for mouse support at the moment) to think of someone else figuring out what my slicing and dicing on top almost 2 decades of spaghetti are doing. It is very hard to write the clean code that I want to write, at any time, but especially when it has to work so closely with stuff that was started so poorly. My employer's only experience with C is the evil stuff that MB86 spits out, so he's not too keen on porting their 300 programs into C from scratch :)

    2. Re:War story by Anonymous Coward · · Score: 0

      Wow. What was wrong with Fortran? And what kind of assembler?

    3. Re:War story by kijiki · · Score: 1

      holy shit. Quit now, and take a bulk eraser to the code and all backups. They'll thank you later.

      And for god's sake, take an AK-47 to the contractor that did that to you.

  29. Thingy! by mmmmbeer · · Score: 4

    In naming functions, make heavy use of abstract words like it, everything, data, handle, stuff, do, routine, perform and the digits e.g. routineX48, PerformDataFunction, DoIt, HandleStuff and do_args_method.

    He forgot "Thingy"! How can you forget "Thingy"? As in "Take the thingy passed in by the user, send it through the thingy, and return the thingy to the user" and "Merge the two thingies, extract the resultant thingy, discard the other thingy, you don't need it here, and then pass the thingy on to the next thingy."

    1. Re:Thingy! by Anonymous Coward · · Score: 0

      if funnybug = true
      blah blah

  30. [OT] Are people missing something here? :-) by Gurlia · · Score: 2

    I'm amused by how many posts here actually took this article seriously, seeing that it came from the "It's funny. Laugh." department. I suppose the phrase "It's funny. Laugh." should be taken in the imperative? :-)

    --
    mikre he sophia he tou Mikrosophou.
  31. arrgh by h2odragon · · Score: 1

    Looked great in preview, screwed when posted. The important flaw is on the last line; I think I can get this one right:


    lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),ran ge(o-1,-1,-1)))


    If you want to post <(&lt;) or >(&gt;) note that the preview form converts the char entities back to characters, and double check 'em.

  32. Not documenting units by jesser · · Score: 1

    24. Never document the units of measure of any variable, input, output or parameter. e.g. feet, metres, cartons. This is not so important in bean counting, but it is very important in engineering work. As a corollary, never document the units of measure of any conversion constants, or how the values were derived. It is mild cheating, but very effective, to salt the code with some incorrect units of measure in the comments. If you are feeling particularly malicious, make up your own unit of measure; name it after yourself or some obscure person and never define it. If somebody challenges you, tell them you did so that you could use integer rather than floating point arithmetic.

    Looks like some Lockheed employee took this page too seriously.

    (numbering might be wrong because i got it from the googlecache version, which has only 53 rules.

    --
    The shareholder is always right.
  33. Don't normally defend sun but.. by TummyX · · Score: 4


    Ignore the conventions in Java for where to use upper case in variable and class names i.e. Classes start with upper case, variables with lower case, constants are all upper case, with internal words capitalised. After all, Sun does (e.g. instanceof vs isInstanceOf, Hashtable). Not to worry, the compiler won't even issue a warning to give you away. If your boss forces you to use the conventions, when there is any doubt about whether an internal word should be capitalised, avoid capitalising or make a random choice, e.g. use both inputFileName and outputfilename. You can of course drive your team members insane by inventing your own insanely complex naming conventions then berate others for not following them. The ultimate technique is to create as many variable names as possible that differ subtlely from each other only in case.



    (e.g. instanceof vs isInstanceOf, Hashtable)

    they are all valid w.r.t the conventions.

    instanceof is an operator and a keyword hence should be all lowercase, isInstanceOf is a method name, hence should start with a lower case character and the rest of the words should be capatilized, and Hashtable is a class name hence every word should start with a capital. Hashtable is the only one you could argue, but I'd say that sun just think Hashtable is one compounded word in itself not two words that describe a class's function.

    1. Re:Don't normally defend sun but.. by Pentagram · · Score: 1

      If it follows the conventions(?), they're arse. I remember trying to use instanceof for the first time. I thought it was a keyword, but instanceOf didn't compile. Neither did other variations. Then I thought, hmm, maybe it's a method in Object. How about .instanceOf() ? Etcetera.

      Actually, why not implement it as a method? Or allow instanceof and instanceOf? Or have a warning in the compiler? Any ideas?

    2. Re:Don't normally defend sun but.. by pspeed · · Score: 1

      Because it's an operator like == != && ||, etc. It requires that the compiler do some magic to the second argument to turn it into the appropriate byte codes for the test. That's why it isn't a method.

      If it really bothers you then there is a method(ical [heh]) equivalent:

      if( MyClass.class.isInstance( myObj ) )...

      Which is oodles less efficient than:

      if( myObj instanceof MyClass )...

      Or, sure, why not allow instanceOf? And since it breaks the keyword convention of being all lower case then lets just throw keyword case sensitivity out the window altogether. Just because it's the only two-word keyword shouldn't matter.

      Then we could do some really interesting obfuscation. :)

      --
      Edu. sig-line: Choose rhymes with lose. Chose rhymes with goes. Loose rhymes with goose.
      Comparing? THEN use THAN.
    3. Re:Don't normally defend sun but.. by TummyX · · Score: 1

      Um, I take it you don't know much about java.
      instanceof is a keyword, it's also an operator.
      instanceOf would be the name of a method call (i believe isInstance is a method in the Class class...it's the dynamic equivalent of instanceof).
      The conventions are fine, and *mostly* consistant.

      The reason it's not a method is the same reason why = ^ | > etc aren't methods.
      What sun should have done is made == an overloaded operator for the String class like they did with + ...but i'll save that argument for another time.

    4. Re:Don't normally defend sun but.. by Pentagram · · Score: 1

      I think its YOU that doesn't know much about Java.

      The compiler doesn't care about case, except for the keywords. instanceOf is a method call because Java doesn't reserve it as a keyword; similarly, instanceof isn't a method call because Java *does* reserve it.

      The guidelines say that keywords should be all in lower case. I'm not disputing that; I just think that they're wrong. As instanceof is the only two-word keyword (except for goto, I suppose), its an anomaly. Non-intuitive and confusing to the beginner.

      Anyway, according to current naming conventions, it should surely be isinstanceof. Or isInstanceOf.


    5. Re:Don't normally defend sun but.. by Pentagram · · Score: 1

      What about goto? Sorry, just being pedantic.



    6. Re:Don't normally defend sun but.. by TummyX · · Score: 1

      ROFL that's one of the funniest things I've read today. Why did you introduce crap about compilers? Did I give you the slightest impression anywhere that compilers are fussy about naming conventions?
      All keywords should be lower case....how does that make _ME_ wrong?

      instanceOf is a method call because Java doesn't reserve it as a keyword; similarly, instanceof isn't a method call because Java *does* reserve it.


      That is also another funny thing I've read today.
      instanceOf is that way cause of the method naming sceheme. What would the fact that instanceof is reserved have anything to do with it. Are you implying that I can't have a method called instanceof cause it's a keyword? ROFLMAO.
      My original post said that all those naming conventions are correct.

      And using "is" is not strictly neeed. Since the operator has already been named instanceof, the method is naturally instanceOf (you can't depreciate keywords).

      It's completely intuitive to me, and like I said in my original post, ALL of what was mentioned is consistant with the java naming conventions.

  34. Some more rules by Raul+Acevedo · · Score: 5
    WARNING: 20 years of looking at, fixing and replacing bad code about to be vented...
    • Put all your code into a single function. (I've seen functions over 2000 lines in length.) After all, those nasty functions generate overhead on each call, and you want your code to be efficient right?

    • Use hungarian notation for variables. Then instead of the overly verbose

      int numLinePayments; char *maxTypeCode;
      you have the nice and compact

      int iNmPt; char *szTyC;

      BONUS: With compact hungarian notation, you can become even more descriptive! So really the above becomes:

      int iLnNmMtCsByPt; char *szMxQtBlTyAcC;
      So much more descriptive information, all in the same amount of space. I've been on projects using this, and the sheer of joy of it cannot be accurately described in words.

    • Don't indent your code uniformly. (This is a variation on #11 from the article.) Use Windoze or vi editors, with non-standard tab widths, for tabbing and indenting, which means that no one can see your code indented properly unless they use the same tools you use, with your same editing configuration.

      BONUS: Write extremely long lines of code, well over 80 characters per line.

    • If using C or C++, don't use memory analysis tools like Purify, or its open source equivalents. After all, if you find your bugs too quickly, you might lose your job.

    • On large projects with several programmers, make sure you change global header files that cause everybody else's code to break but yours. Do this late in the afternoon, so all hell breaks loose breaks right before people are going home, or late at night, so that everybody comes in fresh the next morning and wonders what the hell happened to the code that compiled perfectly when they left the day before. Either way, make sure you are not around when they find out! Otherwise you spare them the joy of figuring out what you changed, and why.

      BONUS: Do this right before a major deadline.

    • Do really stupid stuff that you were taught from day 1 not to do, but everyone seems to do anyway: don't check for NULL, fix array sizes where you hardcode the max size everywhere, don't check for invalid or oversized input, etc.

    • Use preprocessor macros. Lots of them. (I was actually on a project where someone suggested using cpp to define macros. For Java. Absolutely brilliant!) The key is to use a single macro for multiple statements, in effect using macros as function calls. Example:

      #define DO_STUFF(x,y,z) if (x else more_stuff(z); \
      mystery(a*2, z-1); \
      for (int n = x; x != foo; x--) \
      more_stuff(n - x);
      Notice the "hidden" use of external variables and functions. Remember, you want to avoid those expensive subroutine calls! And think of the joys of setting breakpoints and stepping through a debugger on that code!

      BONUS: Don't use the all uppercase convention in macro names; use the same naming convention as function calls. It's even more fun to debug when you have to spend time actually figuring out do_stuff() isn't even a function call!

      MORE BONUS: Nest macro calls. Use the naming convention above.

      EVEN MORE BONUS: Use macro calls as variables. Make sure the expanded macro makes function calls. Or uses other macros.

    • Don't use source code control. Or, use it, but never unlock or checkin your files. Feel free to steal locks on others, though.
    And finally, one of my favorites, for all the young and aspiring hacker types out there:
    • Write code only for yourself. Assume no one will ever need to figure out how to use your code without poring through it in painstaking detail. Do not make it easy to use, interface with other code, or even compile. Include 30 caveats that would take you only a few minutes to fix, but you're just too lazy to. In other words, write as if no one will every look at or use your code, yet release it to everyone to look at and use. Defend your laziness, which is causing thousands of lost hours of work to others, by uttering useless and stupid "cool hacker" mantras like "Real Programmers don't write documentation" and "If it was hard to write, it should be hard to understand."
    Phew. That little tirade made me feel good. :)
    ----------
    --
    In a real emergency, we would have all fled in terror, and you would not have been notified.
    1. Re:Some more rules by Anonymous Coward · · Score: 0

      LibTIFF reaches astounding levels of macro abuse. No offense to Mr Leffler, as TIFF itself is a nightmare, and i do appreciate him making this code available, but look at some of the code in tif_getimage.c .

      for example :

      #define REPEAT8(op) REPEAT4(op); REPEAT4(op)
      #define REPEAT4(op) REPEAT2(op); REPEAT2(op)
      #define REPEAT2(op) op; op
      #define CASE8(x,op) \
      switch (x) { \
      case 7: op; case 6: op; case 5: op; \
      case 4: op; case 3: op; case 2: op; \
      case 1: op; \
      }
      #define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; }
      #define NOP

      #define UNROLL8(w, op1, op2) { \
      uint32 _x; \
      for (_x = w; _x >= 8; _x -= 8) { \
      op1; \
      REPEAT8(op2); \
      } \
      if (_x > 0) { \
      op1; \
      CASE8(_x,op2); \
      } \
      }

      uh????

      REPEAT4(op) is just a way of writing "op;op;op;op;" . why the aversion to "for" loops?

      CASE4(x,op) is a way of repeating op 0-4 times, depending on the value of x. again, what's so bad about a "for" loop?

      UNROLL8 does REPEAT8, w/8 times, then does a CASE8 for the remainder. again... what's wrong with a for loop?

      it makes the code essentially impossible to debug. to find out what was actually going on, i expanded all of those macros by hand and turned 7 line functions (whos definitions were made from macros!) into 150 line monsters.

      absolutely astounding.

      -c

    2. Re:Some more rules by ucblockhead · · Score: 1
      BONUS: With compact hungarian notation, you can become even more descriptive! So really the above becomes:

      And if you have to change a variable's type, don't bother changing the prefix. It is just a guideline anyway. and changing all occurances would be a pain (Real programs don't use search and replace):


      unsigned char iLnNmMtCsByPt; long* szMxQtBlTyAcC;


      --
      The cake is a pie
    3. Re:Some more rules by Kenelson · · Score: 1
      Use preprocessor macros. Lots of them. (I was actually on a project where someone suggested using cpp to define macros. For Java. Absolutely brilliant!) The key is to use a single macro for multiple statements, in effect using macros as function calls. Example:

      Far better is to use some preprocessor which is not even included in the language. For example choose some obscure preprocessor whose notation is in direct conflict with internals of the language. This causes the source code to become meaningless programmers. Then write long procedures into macros and construct them into massive unformated and unreadable procedures. If you are really good, have the macros change throughout the code or perform different functions depending on hidden arguements. Redefine keywords to match macro definitions so that you can't tell the difference between the preprocessor and language. I can personally recommend m4 for the task.

      --Karl

    4. Re:Some more rules by Abigail-II · · Score: 1
      On large projects with several programmers, make sure you change global header files that cause everybody else's code to break but yours. Do this late in the afternoon, so all hell breaks loose breaks right before people are going home, or late at night, so that everybody comes in fresh the next morning and wonders what the hell happened to the code that compiled perfectly when they left the day before. Either way, make sure you are not around when they find out! Otherwise you spare them the joy of figuring out what you changed, and why.

      Ah, but then you have to depend on other people compiling their stuff, and you won't break anything that's already submitted to the QC department. It's much better to take one of the major dynamic libraries, change the interface to a commonly used function (say, a routine that inserts rows in a database), and then recompile and submit the library, without changing its major number. Then at least you can break everything that's already working.

      Also, comment all your code. Make lots of comments. And then PGP encrypt the comments.

      Put lots of warnings in the code. As in:
      /* If you aren't 100% certain what this does, DO NOT CHANGE IT */

      And one of my favourites: /* Magic */

      -- Abigail

  35. Mirrored here, by augustz · · Score: 0
    Mirrored here

    Enjoy

  36. Mirrored here - really :) by augustz · · Score: 3
    Mirrored here

    Enjoy

  37. Mirrored here... by augustz · · Score: 1
    Mirrored here

    Enjoy this

  38. Bad mirror by augustz · · Score: 1

    I miss-typed that url... Sorry...

  39. Job security? try fortran by craw · · Score: 1
    The best way to maintain job security is to have legacy code written in an out-dated programming language. And as far as obscure coding goes, what is better than writing in a language that is no longer taught to the kiddies that may take your job away.

    You may laugh at this. I don't. We have a Fortran programmer that wrote a lot of legacy production code (for the Vax). I know fortran (at least up to fortran77) although I haven't written in this language for a long time. Some of the younger ppl trying to port the code to newer systems have had a miserable time. But, hey, no problem! This guy is going to port his code to run on a unix system and will rewrite in C. No wait, he decides that he will skip c and rewrite the code in a new language that he hears is all the rage; c++. Two years go by.

    He gives up learning c++ and ports his code to c. Another two years go by. If you know fortran, then you know that character manipulation is a bitch. I check his code and realize that he does not know the rudimentary aspect of c. He has essentially rewritten the function atoi. yikes.

    On a side note: Obscure variable names is nothing new. Take a look at old fortran code written for a system with a 8 character limit.

    On another side note: Many, many moons ago in my 1st computer class (fortran), I wrote a program that used the variable names kitty, cat, meow, and woof. Kitty was the integer equivalent to cat, and meow was the integer equivalent to woof. The prof was not pleased despite my explanation of the brilliance of my choice of variable names.:)

    1. Re:Job security? try fortran by Anonymous Coward · · Score: 1

      He probably ran f2c the first day on his new job and then took a 4 year in cubical sabatical...

      *LOL*

    2. Re:Job security? try fortran by Shimbo · · Score: 1
      It's disappointing that the all work done on Fortran 90 and 95 has gone largely to waste because of the absence of open source compilers.

      If C++ folks can get away with statements like "if you don't know C++ version 3, you don't know C++", you should IMHO not write Fortran off until you know at least Fortran 90 (mixed case). Hell, it's not even the current version anymore.

      Everyone and his mother has an opinion about Fortran - but usually based on out of date ideas.

      Fortran still works well for what it is designed for - number crunching in scientific/engineering environments.

    3. Re:Job security? try fortran by CaseyB · · Score: 1
      On a side note: Obscure variable names is nothing new. Take a look at old fortran code written for a system with a 8 character limit.

      8! Luxury! Earlier forms of BASIC had a 2 character limit. Actually, (and this is perhaps the best obfuscation facility I've ever seen) on the old Commodore 8-bit machines, you could make variable names as long as you liked. But only the first two characters were significant.

      10 outputone$ = "foo"
      20 outputtwo$ = "bar"
      30 print outputone$

      >run

      bar

    4. Re:Job security? try fortran by Pig+Hogger · · Score: 1
      > 8! Luxury! Earlier forms of BASIC had a 2 character limit. Actually, (and this is perhaps
      > the best obfuscation facility I've ever seen) on the old Commodore 8-bit machines, you could make
      > variable names as long as you liked. But only the first two characters were significant.

      And even that was a BIG improvement on those moronic basics who would only allow you variables named [A-Z] or [A-Z][0-9]!!!!
      -- ----------------------------------------------
      Vive le logiciel... Libre!!!

  40. legacy code kills by Pope · · Score: 1

    Having spent most of this year climbing through other's crappily written legacy HTML, it was such a nice change to have to write my OWN code from scratch starting in October.
    I was handing off pages to our PERL and PHP programmers, and they knew *exactly* where everything they had to do went, and why.
    I only commented a few sections, but by gum they were the important ones.
    Now I'm reusing 70% of the code to do 3 sections in one month, whereas the last section took a whole month to do.
    If this continues, I'll work myself into a looong paid vacation :). As it is, I only "work" 5 hours out of the 8 I get paid for. After the last month, I "deserve" a break.
    It'll be back to normal come December when the new stuff comes in, but right now, I'm enjoying the fruits of my labour.
    Work smarter, not harder, neh? :)

    Pope

    --
    It doesn't mean much now, it's built for the future.
  41. passwording function names by sklib · · Score: 1

    To make your code understandable only to you, you do not need dozens of methods -- you need only 1. Apply password selection procedures to function names. Remember, a password is your dog's name, but with numbers in it (like your vet's phone number modulo its greatest common factor with 3) and written in h4x0r-speak.

    --
    -S
  42. Sowing confusion by mmmmbeer · · Score: 1

    I have a cow-orker (we're both programmers) who once spent a day lauding the benefits of word wrap in editors, despite denials from the rest of us. Now I indent all of my code so that the lines just "happen" to wrap in such a way that it seems to nest wrong only for him. >:)

    1. Re:Sowing confusion by Anonymous Coward · · Score: 0

      You have a cow orker?

      Who's orking the cows, here?

      I'm scared now.

  43. for(int i=5; i -->0;) by Carnage4Life · · Score: 1

    My mistake, posted too hastily it should have read more like.

    int i=0, x =5;

    for(i=x; i-->0;) { //do stuff }

    Bad Command Or File Name

    1. Re:for(int i=5; i -->0;) by Anonymous Coward · · Score: 0

      I often write code like that. Except I don't usually use that >0 part. In my opinion that kind of loops are often much easier to understand if you have used them before. And on many machines they are also faster than the increasing version (often it's easier to compare against zero than agains some variable or constant).

    2. Re:for(int i=5; i -->0;) by Harik · · Score: 1
      it is. compare against a constant is often equal to subtracting the constant and checking the zero flag. (cmp is a sub but dosn't modify the operands if I remember right. Been too long since I've hit the bit level) Whereas a decrement sets the zero flag for you, so you save an instruction per loop.

      it breaks down to:
      add 1
      compare 10
      jump if zero

      versus:
      subtract 1
      jump if zero

      --Dan

  44. This is news? by Trelane42 · · Score: 1

    I stumbled across this unmaintainable code article a long time ago (early this year, I think) while looking through the Java glossery, hosted at the same site. Why is it just being reported now?

  45. Nested Ternaries by Vrallis · · Score: 1

    Hey, I resent them mentioning these beauties! I love using nested ternaries. Strange no body else does, but I actually think they are quite usable.

    Then again, I don't get much opportunity to use them these days...damn 4GL gibberish =)

    1. Re:Nested Ternaries by sfbanutt · · Score: 1

      Nested ternaries are great. I once wrote a function to do ROT-13 transforms on text using a for loop and a very deeply nested ternary. It crashed MSC 5.0 (couldn't handle the nesting...)

      --
      I've wrestled with reality for 35 years and I'm happy to say, I finally won out - Elwood P. Dowd
  46. Variable names by blogan · · Score: 2

    The site was slashdotted, so this might be on it. What I like to do:

    Name variables a series of l's (the letter) and 1's (the number). So you'll have:

    ll1l1lll1
    ll11ll1l1
    1ll1l1l11
    ll1111lll

    and so on. Sure, if they use a font that clearly shows the difference, it's no fun. But it can be!

    1. Re:Variable names by tlhIngan · · Score: 1

      1's and l's? tsk. A common irritant I have are those pesky l (lowercase L), and I's (uppercase i's). An amazing amount of fonts I use don't make the distinction (one vertical stroke).

      PITA when you get passwords in email, and therefore can't guess if it's l or I.

      (Hint to make more unmaintainable code: Choose a nice font that has this property. Lots do, don't worry, and make it the default font for all coders ).

    2. Re:Variable names by ucblockhead · · Score: 1

      At one company I worked at, we literally spent a month trying to fix a bug that boiled down to telling the difference between the strings:

      "PROFILE_ADMIN_BLAH_BLAH_BLAH"

      and

      "PROF1LE_ADMIN_BLAH_BLAH_BLAH"

      This was in the old DOS days, and the font, as you can probably guess, used the exact same representatin for "I" and "1".

      Which brings me to another rule. (Haven't checked the list. It's slashdotted, so this may be redundent.) Replace all your macro constants, which are checked at compile time with strings that are checked at runtime. Don't laugh. I ran into a very large project that did this, and to make matters worse, did the following literally hundreds of places in tight loops:

      #define PROFILE_ADMIN_BLAH_BLAH_BLAH "PROFILE_ADMIN_BLAH_BLAH_BLAH"

      Tag = PROFILE_ADMIN_BLAH_BLAH_BLAH
      /* Lots of code */
      if( !strcmp(PROFILE_ADMIN_BLAH_BLAH_BLAH, Tag) )
      {
      /* Do lots of equally inane stuff */
      }

      The good news was that I had been called in to "optimized". Management was amazed that I was able to dramatically speed up program execution. Sometimes other people's crappy code can be good for your career. :)

      --
      The cake is a pie
  47. Spirit Breaking 101 for Junior Porgrammers. by Anonymous Coward · · Score: 5
    as a cs student, nothing inspires me more! job security rules!

    Good evening class. I'll be your exorcizer of idealistic nonsense for the evening. Just call me Bruce.

    Now... preach all you like about how hard it'll be for the next guy, but like customizing my car or my house... I don't worry about what the next guy will think about my code. Do you care if the next owner of your car might not like it if you paint it red? Do you care if the next owner of your house disapproves of you converting the garage into a pool room? Heck no. Well, it's the same with me. I work for my own benefit, pleasure, and satisfaction. And to do that I've gotta do the best damn job I can at work. Otherwise; no money; no fun. This philosophy is reflected in my code as well. I've cranked out some godawful nasty kluges that confuse even me when I look at them a year later... but I got the job done, by the deadline, while some of the junior programmers seem to wanna rewrite everything to make it clean rather than break the nice design of the code. Feh. That's why they're junior programmers. They Just Don't Get It (tm). Their plan would send the company under. Stuff's gotta be done now and ship next week or there's no profit for the company and no salary for the programmers. Junior programmers always seem to be self-delusional with grand plans of redesigning everything. It never happens. Requirements change *ALL* *THE* *TIME*. Any static plan is doomed to fail. Once they realize this they make the transition from dreaming programmer to master hacker... or they can't keep up with the pace of real world business and disappear. You've got to be able to deal with old crusty projects written by long gone staff with more bags and bells and whistles and ornaments hanging off the side and kluged into it, written by more people you've never met, and you've got to be able to quickly and successfully hack more stuff into it and hack it and rehack it and change old stuff and keep it all running. Successful, on the fly, under the gun kluging is what distunguishes the Senior Programmers driving the big smog polluting, shitty mileage, comfy luxury cars into the front, covered parking space and getting the stock options and profit sharing and 401Ks from the idealist larval dreamers driving their small car becuase "it's good for the environment". Self-spirit-lifting-and-self justification-bull. Given the Big Bucks, you'd ditch that Civic for a gas guzzling SUV or Corvette too. So forget the dream. Getting a clean slate to build on is a rare event. 99% of all programming jobs you'll ever be hired for will be holding together someone else's code. Insane deadlines, getting the jump on the competition mid project, reamping of requirements (many times over), decision reversals by management, your latest self-gratifying achievement being abandoned and dumped because it's not needed anymore. These will all eventually break your spirits. On the plus side, once you realize this, you will be able to succeed and advance within your company or find it easy to get hired at the next comapny. because quick thinking master hackers who can do the magic again and again despite laying waste to the original vision and still keep on kluging and have it keep on working are what companies want. If you can do this, you will succeed. Getting back to the original question... do I obfuscate my code? It may certainly look that way to the idealist, but not so. True brilliance is messy. Remember the famous comment preceeding the task switching code in Unix... /* You are not expected to understand this */ But if you can, you'll be a god... or root... what's the difference again? Anyway, class dismissed.

    1. Re:Spirit Breaking 101 for Junior Porgrammers. by pedro · · Score: 1

      Best AC post I've seen in a very long time.
      I don't know whether to hug you or hunt you down, tackle your sorry ass to the ground, gnaw through your rib cage and tear your still beating heart out with my bare teeth.
      Ain't ambiguity great?

      --
      Brak: What's THAT?
      Thundercleese: A light switch.. of TOTAL DEVASTATION!
    2. Re:Spirit Breaking 101 for Junior Porgrammers. by Anonymous Coward · · Score: 0

      In my experience the reason that most people program badly is that people don't understand the problem that they are supposed to fix.

      Most people get a fuzzy idea of a specification and dive into programming the first day. Then they goto the users and the users say, well that is nice, but we wanted it to do this, so they change the code again and again, adding the features that the users _always_ needed from the beginning until in the end the code is so messy and poorly written that it barely runs.

      Here is my patented 8 week project plan.

      The one true way to write a program is to goto the users and say, let me work as one of you for a week. Take your notepad and listen to what they say, ask questions when you aren't sure of something. Actually do the work and see what is good and bad about how the users are currently doing their job.

      Go back and take a week to write up a detailed specification with screen shots of what the product will look like and flow sheets detailing how the work is to be done. Detail the resources you need and the time that it will take to implement the plan. Take these to your boss and the users and get everyone to sign off on these specifications. If the users have a deadline that is before you can accomplish everything they want, see what they need now and leave the rest for a later project.

      _NOTE_ To this point I haven't written a single line of code so it doesn't matter how much the requirements have changed.

      Once you get the agreement and only then, write the code in one week. It will be easy because you will understand the problem so well.

      Take a second week to unit test everything and fix your mistakes.

      Take a third week to do final testing with the users. Any major new features that the users want at this point will be added as an seperate improvement project.

      The fourth week you check in your final code and implement your solution.

      The fifth week you work with the users to find and fix bugs that escaped the testing.

      The sixth week you finish up your documentation and trouble shooting instructions.

      At this point you will normally never have to deal with the improvement project because these phase II projects rarely happen. You will normally start a new project.

      When you can complete a series of small projects in a shorter period of time there is less chance of feature creep in any one of the projects. Features that users think would be nice to have but aren't important will tend to accumulate into enhancement projects that are done as a seperate project at a later time.

    3. Re:Spirit Breaking 101 for Junior Porgrammers. by Anonymous Coward · · Score: 0

      I just realized..... you are totally correct!
      I have been working at internet companies now
      for 4 yrs. I am considered a very successfull
      programmer, I make lots of money and have lots
      of stock options (NO I DON'T WORK FOR MS DAMNIT!)
      The above post very accurately puts into words
      my whole job. My bosses love it and think I do
      a great job. And yes Jr. Programmers, you will
      get fired if you can't hang.

    4. Re:Spirit Breaking 101 for Junior Porgrammers. by Anonymous Coward · · Score: 0

      You obviously don't work at an internet company.
      It sounds like you develop "in house" software.
      Your techniques would cut my company's market cap
      in half.

    5. Re:Spirit Breaking 101 for Junior Porgrammers. by Anonymous Coward · · Score: 0

      You're absolutely right, writing the software that has only the features that the users want and writing it correctly and maintably the first time would hurt your company.

      You need to write software right now, before you know what the users need and get it out the door, they probably won't hire you back to do more work anyway...

      What does it matter what "kind" of company someone works for? Do internet programmers not program?

      And I am not talking about setting up a web site with a couple of cgi scripts. I am talking about writing real programs with hundreds of users that will still be in production in 10-20 years and will need to be modified several times over the years to match changes made in other system.

      I work for hospitals interfacing their patient care systems (REG/ADT, Lab, Pharmacy, Pathology, Clinics, Decision Support) together. So in my field it is more important to be correct and not kill patients than it is to get the project out the door.

      But in my estimation it is important to do quality work no matter what kind of work you do. If you have to dig ditches, be the best ditch digger that you can be. If you have to program, be the best programmer that you can be.

      If you follow my plan each of your programmers can produce 6 projects a year. If you had 10 programmers that is 60 projects a year.

      How many projects a year do you perform right now?

      You can even specialize people.

      Some people are really good at writing specifications. These people can write two specs a week.

      Some people are really good at writing quality programs from specifications, these people can finish writing and testing a program in half the time of other people.

      Someone who is good at both writing specifications and programs is invaluable. Pay them what they need. Heap them with praise and make them the team leaders over the others.

      People who can do neither do not make good programmers. Put them as far away from writing programs as you possibly can. And for all of our sakes, don't let them become managers over programmers...

    6. Re:Spirit Breaking 101 for Junior Porgrammers. by Anonymous Coward · · Score: 1

      Hello class. Now that the professor has left, the Teacher's Assistant will clean up the mess. Please forgive him, he's a young, but crusty fool that occasionally makes some valid points, but I'm afraid he's way off the mark in other areas.


      The first mistake I'd like to clear up, is the class title. Just because a programmer codes cleanly is no indication that his spirit has been broken. In fifteen years of programming (that's after Uni), I've noticed that source code is a fairly good indication of thought process. If the code is badly laid out or badly commented, it's a good bet the programmer didn't know what was going on -- he was just typing until things worked. (Or in some cases, he was consumed by his own cleverness.)


      His second mistake was the car/house analogy. He's absolutely correct that we don't/shouldn't care what he does to his Rumpus Room or '66 Muscle Car. Unfortunately, the software we're talking about is not a private Rumpus Room. It's a bridge ... on a heavily used interstate. If a bolt starts to work loose, the DOT wants to find it, pull out a standard crescent wrench and tighten it up. They do not want to spend two weeks admiring the "artistry" of how the original bridgemaker met the schedule by using a one-of-a-kind unlocatable tool to attach two pieces.


      He is correct that, once you leave Uni, you will find that practice wins out over theory. Alot of Software Engineering theories are (at worst) claptrap, or (at best) a germ of a good idea wrapped in layers of claptrap.


      This, however, does not excuse you from writing clean code. Document tricky solutions. If you don't document tricky solutions, people will correctly assume you didn't really understand what you were doing.


      Also, arrogance will come back to bite you. I once saw a programmer publicly (and sweetly) toasted because the comment

      /* Don't change this, because you're too stupid to understand it */

      The toasting came from another engineer because the code which followed that comment was not only convoluted, but it contained an error.


      Thank you class. Your homework assignment for next week is to realize three things:

      1. There is a balance between deadlines and good code.
      2. There is a balance between "artistic freedom" and uniform standards.
      3. How well you strike these two balances determines your overall worth as a programmer (in both a spiritual and a monetary sense).


      Have a good holiday. Class dismissed.


      Anonymous Kev

    7. Re:Spirit Breaking 101 for Junior Porgrammers. by pieguy · · Score: 1

      I guess I know why I spend so much time finding bugs and fixing shitty code. I've known for a long time that it's better for a career to supply buggy crap on time than to supply stuff that works all the time but is occaissionally late. Then, of course, you get to be the hero when you fix your crap. About the only people who complain are the users and who cares about them. I resigned one place because the programmer who completed every project on time, but always spent 3 weeks fixing production problems, was the fair haired annointed destined for greatness. The only person who expressed dismay was the operations manager who got called at 3 AM every time this bozo's stuff crashed. He told me that I was the only analyst who could put something into production without him worrying about being awakened in the middle of the night. But on one project I was 2 weeks late due to a technical problem that took 2 weeks to solve. I knew I didn't have a future there. But it's certainly my belief that Bozo's rule in this field, especially when I come along behind bozo's like this guy.

      --
      ------------------------------------
      knout (n) - A leather scourge used for flogging
    8. Re:Spirit Breaking 101 for Junior Porgrammers. by pieguy · · Score: 1

      Hooray for some sanity. Let's hear it for keeping things simple and clear. There is no excuse for writing complex cludgy convoluted code when if you just take the time to do some THINKING, you can generally design a program to be simple and easy to understand and follow. Any extra time you spend on thought will pay dividends on the test and debug. Of course, if you don't do any testing I guess it's wasted time, isn't it?

      --
      ------------------------------------
      knout (n) - A leather scourge used for flogging
    9. Re:Spirit Breaking 101 for Junior Porgrammers. by pieguy · · Score: 1

      You live in the same fantasy world that I live and work in...needless to say, while I've survived in the IS world for a long time due to the fact that my code always works, I've never had what could be considered a successful career.

      --
      ------------------------------------
      knout (n) - A leather scourge used for flogging
    10. Re:Spirit Breaking 101 for Junior Porgrammers. by scrytch · · Score: 2

      I don't know whether to hug you or hunt you down, tackle your sorry ass to the ground, gnaw through your rib cage and tear your still beating heart out with my bare teeth.

      I uh ... I'm not sure I'd want you to hug me either, now...

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
  48. Your employer was a buffoon by Anonymous Coward · · Score: 0

    Whom ever hired you should have provided more oversight. This is a common mistake in our industry, hiring students to write grownup code. There is a difference between being an adult and a child. You my dear boy are a child. Those of use who intend on making a career in software engineering behave like professionals, we do due diligence and write solid, maintainable code. If you end up in the industry for a while you would soon notice that it's a small world, and you develop a reputation.

    1. Re:Your employer was a buffoon by CFN · · Score: 1

      Hey AC, I don't want to start a war, but why don't you post some solid, maintainable code so some of us children can learn from a master.

    2. Re:Your employer was a buffoon by Anonymous Coward · · Score: 0

      I'm a different AC, but I agree 100%. I'm still a student mind, and I think there are plenty of students who are quite competent software engineers despite relatively little experience (see the Universities poll for more discussion of that). However, anyone who writes unmaintainable code on purpose is simply not very professional.

      It's obvious this guy's employer was foolish, and that whoever was overseeing things wasn't a technical person at all. In a serious project that is managed by competent people where you're working with other developers, there's simply no way you can get away with such carelessness and unprofessionalism.

    3. Re:Your employer was a buffoon by johnstonwinn · · Score: 1

      companies are scared to change, so they have to work with what they got.

    4. Re:Your employer was a buffoon by Anonymous Coward · · Score: 0

      If you end up in the industry for a while you would soon notice that it's a small world, and you develop a reputation.

      Pardon me, but IMO this is bull. It's NOT a small world. There are so many programming jobs in so many different fields that it would be a major task to even begin to list them all. You seem to have a very very narrow definition of "the industry".

      Those of use who intend on making a career in software engineering behave like professionals, we do due diligence and write solid, maintainable code.

      And those of us who already have made a career in software have seen so many idiots, morons, simpletons, and puffed-up arrogant fools writing crap -- and having quite successful careers doing so! -- that we know your statement is false. Battling against the legions of fools is a waste of time... even if you take every piece of crap code handed to you and turn it into gold, the moron after you will turn it back to crap.

  49. Job Security! by GeorgeMcBay · · Score: 1

    With all the talk of job security (I realize most people are saying it with tongue-in-cheek), you'd think we were auto-assembly-line workers. If job security really is an issue for you, you must be a damn poor programmer to start with.
    Now, having said that, the link in question was undoubtable funny, and I'm sure none among us can cast the first stone when it comes to the listed offenses, though I doubt most really do it for job security. Usually, its the insane deadline pressure or the dreaded feature creep.

  50. Some things I've seen... by Anonymous Coward · · Score: 0
    #define SEVEN 5

    ..and...

    a 210 line macro (in an 11,000 line .c file), ugh.

  51. Slashdot Poll? by carleton · · Score: 1

    How many of the suggestions have you done:
    None of them; all of my code is squeaky-clean
    1-5
    5-10
    10-15
    20-40
    40-50
    All of them, and proud of it.
    3 + 6i of them
    Hey, what about 16-19?

  52. Ha you should try reading... by wilkinsm · · Score: 1

    the MSDN sample code. They must use these rules as their "White Paper."

    I got a few more:
    - Routinely switch using null and non-null terminated strings. Bonus points for encoding in EBSDIC.
    - Routinely change your array bases from 0 to 1 and back.
    - One Word: LISP.
    - Routinely use double-indirected pointers to undefined structures.

    Okay, I'm done.

    1. Re:Ha you should try reading... by Anonymous Coward · · Score: 0

      Dude its EBCDIC and it rules of RS/6000's, don't slam IBM "innovations!"

  53. After all, if the Stroustroup can use the shift op by Anonymous Coward · · Score: 0
    to do I/O, why should you not be equally creative?

    My god he's right! ^ is finally gonna do exponentation just like it fscking should!

  54. Ack. Byline is wrong. by Rendus · · Score: 1

    The by line should read "Rob Malda." Rob wrote this as a guideline when working on Slash 0.4, and decided to publish it. He will be teaching a class on this at the Slashdot booth, located in the Linux Business Expo portion of Comdex on Friday.

  55. #define TRUE ('/'/'/) by Anonymous Coward · · Score: 0
    and

    #define FALSE ('-'-'-')

    Fun and harmless. (Do all compilers evaluate numeric expressions at compile time?)

  56. Re:Cow-orker by mmmmbeer · · Score: 1

    To clarify: "cow-orker" is an intentional misspelling of co-worker. I just like the way it sounds. I picked it up from the Dilbert List of the Day. It's not uncommon there.

  57. LISP is the MOTHER of bad looking code by Anonymous Coward · · Score: 1

    You want to see unmaintainable code ?
    Try and read Lisp Code.
    I have seen Lisp code that the last 4 pages of the program were ")".And i am not kidding.

    Tail recursion babyyyyyyyyyyyyy!!!!!!

    1. Re:LISP is the MOTHER of bad looking code by joey · · Score: 1

      That's what ] is for. (Well, in some lispish dialects anyway, it closes all open parens.)

      --

      --
      see shy jo
    2. Re:LISP is the MOTHER of bad looking code by Anonymous Coward · · Score: 0

      Lisp can be very daunting at first as it does look different from more common languages. But Lisp code can be very readable. Especially when programming in a functional style (no side effects). The main problem is that it can be very terse compared to languages like C, C++, Java, doing a lot in a few lines of code. Understanding 5 lines of lisp might be equivalent to understanding 30 lines of C so don't be surprised if it takes 6 times as long. You should have more comments per line of lisp code than line of C code for this reason too, and your functions should be smaller, 5 lines of code per function is usually enough.

    3. Re:LISP is the MOTHER of bad looking code by Anonymous Coward · · Score: 0

      Lisp can be very daunting at first as it does look different from more common languages.

      But Lisp code can be very readable. Especially when programming in a functional style (no side effects). The main problem is that it can be very terse compared to languages like C, C++, Java, doing a lot in a few lines of code. Understanding 5 lines of lisp might be equivalent to understanding 30 lines of C so don't be surprised if it takes 6 times as long.

      You should have more comments per line of lisp code than line of C code for this reason too, and your functions should be smaller, 5 lines of code per function is usually enough.

    4. Re:LISP is the MOTHER of bad looking code by fReNeTiK · · Score: 1

      This looks like a very bad idea to me. Closing all ) means you end up closing the wrong ones... Use an Eeditor which highlights the ()...
      --

      --
      I strongly believe that trying to be clever is detrimental to your health. -- Linus Torvalds
    5. Re:LISP is the MOTHER of bad looking code by Anonymous Coward · · Score: 0
      This looks like a very bad idea to me. Closing all ) means you end up closing the wrong ones...

      No, it doesn't mean that. It means you don't have to count )'s and it means the lisp form will be properly closed.

      Use an Eeditor which highlights the ()...

      Use both...

  58. Re:slashdotted - use google by Anonymous Coward · · Score: 0

    BTW, google.com mirrors a lot of the web

  59. The Shoemaker by keytoe · · Score: 1

    I don't think anyone has commented on the final section of this essay yet, so I'd like to bring it up.

    Think of what might happen if we started storing source code as structured data.
    We're all working in algorithms - essentially, pure ideas. If there were some way to boil your ideas into some universal language (structured data) then you've hit on that ideal: Truly Reusable Code.

    I recall reading The Glass Bead Game recently and ended up thinking along these same lines then - perhaps this is where it starts? Its all about abstraction, after all... Go far enough and it all fits under the same umbrella.

    1. Re:The Shoemaker by MattyT · · Score: 2

      I don't know that it's necessarily possible to get a "universal language", but an algorithms repository with a set of translators to other languages would be cool, to the extent it can be made to work.

      That being said, there is at least one project to create a language and editor that use "structured data" like he describes, which I founded, see "http://www.box.net.au/~matty/ultra". I'm not going to claim it will be a universal language though!

    2. Re:The Shoemaker by HalloFlippy · · Score: 1
      We're all working in algorithms - essentially, pure ideas. If there were some way to boil your ideas into some universal language (structured data) then you've hit on that ideal: Truly Reusable Code.

      As I understand it, this is what the Unified Modeling (Meddling?) Language (UML) people are trying to do. Start with an abstract, graphical notation to plan out your system and document it right from the start. From what I've seen, some tools already have code-generation ability (Rhapsody, Rational Rose, ObjecTime). The idea isn't so much reusable code, but something that could create code (ideally in any language) from a set of specifications.

      --

      I am a man of const int sorrows
  60. Jelloooo by sklib · · Score: 1

    Me and a friend of mine were writing a physics demo program as a class project a couple of years ago, and we made heavy use of picking insane names for classes and variables. As an example, one of the objects is a bond that obeys Hook's Law, but that needed a manager. So we called the manager a Pimp class. And the instanciation was myPimp. The function that told each bond to update itself, if I remember correctly, was actually called DoIt or something horrific like that. Then there were Erectangles that covered the surface of the solid we were generating... oh man, that was fun.

    --
    -S
  61. No goto by heroine · · Score: 2

    Well I'm still a staunch opponent of using goto. Maybe goto makes you feel superior because you're using Microsoft's crown jewel of BASIC programming but unless you've got employers to impress Microsoft isn't everything.

    1. Re:No goto by Anonymous Coward · · Score: 0

      Actually goto is very useful if you are nested several layers deep and need to break back out to the highest level.

      The clasic example is that you are seaching a 3 dimensional array using nested for loops and you find what you are looking for. A break would only break out of the third level to the second level. The goto can jump down to where you actually use the answer that you found.

      Other than this the use of goto should be justifed on a case by case basis. Most problems can be solved elegantly without the use of GOTO.

    2. Re:No goto by Abigail-II · · Score: 1

      There are a few case where goto remains useful.

      And of course, things like 'break', 'continue', 'last', 'next', 'redo', are nothing more than glorified gotos.

      -- Abigail

  62. sloppy code can get you fired by xyster · · Score: 1

    at an ISP i used to work for a programmer got fired for writing such horrible code that was very difficult to understand (he had no formal coding training) i.e. if his program core dumped, he just wrote a wrapper to delete the core so it would keep running. eventually when we tried to update all of our machines we couldnt because his code was so limiting and no upgradable.

    lesson learned: do not promote your own job security through obscurity. you'll get burnt in the end.

  63. Of Course It Has A Spanish Version by grantdh · · Score: 1

    Naturally there's a version in Spanish. After all, one of the key rules is to always write your comments in a foreign language. They're there, they're up to date, they're helpfull but they're totally confusing to the poor bastard who winds up maintaining the system.

    Ahh, the joys of multi-lingual development teams!

    :)

    --

    I left my body to science, but I'm afraid they've turned it down...
  64. Job security by phantomlord · · Score: 3

    Remember the old motto...

    If you can't be replaced, you can't be promoted.

    --
    Don't leave your mind so open that your brain falls out. Don't close it so much that you cut off the blood.
  65. Re: dogs by h2odragon · · Score: 1

    Somebody suggested that training method when I was raising my first puppy. Now she's addicted to pepper sauce and beer. Dogs do not digest spicy foods well...

    "if you let someone get burned by their own bad habits, it is sometimes enough to break them of those habits."

    And sometimes it just makes a big stink. :)

  66. You're living in a dream world... by Anonymous Coward · · Score: 2

    ... if you think anyone would EVER be a victim of this practice. You think they want to rewrite the whole thing from scratch just to have the joy of firing you. I had a prof who told us his strategy when he worked as a programmer - leave the company so that they have hire you as a consultant at four times what you were making because you are the only one who can figure out your code. Brilliant! I used to write maintainable code. My boss once told me how great my coding and commenting was because anyone who came along later could figure it out. Then he retired. The next recession things slowed down, and I got cut because any newbie could read my code and build on it, while everyone else stayed around because they were invaluable - their coding was complex. I would tell people in interviews about my boss's comments on my code maintainability, AND THEY DIDN'T CARE. It's a moot point with employers, they don't have the vision to look ahead and value maintainable code, and they will throw you on the street the first chance they get if it doesn't hurt them. So I say screw them and make yourself invaluable.

    1. Re:You're living in a dream world... by Anonymous Coward · · Score: 0
      Where I used to work they went through one of those awful TQM process thingies. Like ISO 9000, only more excruciating.

      Everyone report to sector G for process efficiency homogenization. Resistance is futile.

      It started with a process of describing your job. Everybody knew why we were doing that. So they could fire the deadwood more easily. I was a computer nerd, and the advice was orthogonal to anything I was doing, but the process didn't exactly whip our morale up into a patriotic frenzy.

      Thank you for completely transcribing everything necessary to do your job. You are fired.



    2. Re:You're living in a dream world... by Anonymous Coward · · Score: 0

      I agree wholeheartedly with this post.

      I think some of the posters here at /. haven't been through a recession. Yet. They've only experienced a job market where it's pretty easy to move on down the road if the place you're at isn't doing things right. Having high philosophical standards is easy in this envirnoment.

      But when things turn tough and people start getting fired, the ones who play nice are the ones who get eaten. Just because we've paved over the jungle, doesn't mean the jungle isn't still there.

      It's all about what is in YOUR best interest. Not the company -- if the company can make $5 more by firing you than by keeping you, you're fired. Not the high gurus of software standards -- way too many of them have tenure.

      If it's to your benefit in a situation to do great code, do great code. If messed up hacking is better, do messed up hacking. The only rule is: does it work, and are you still getting the money?

  67. This is largely your own fault by lars · · Score: 2

    It is apparent that your company is using a very ad hoc development process. It is UP TO YOU to work to change this, particularly if you're working with a lot of non-technical people. Try and convince your management to implement a formal development process. For each project, write a requirements document. Make several parties sign off on it. Make it so that any change to the requirements also has to be signed off by all parties. Whenever they requiest a new feature, simply tell them: "Adding feature x will take another 10 days. Either we can push the schedule back by 10 days, or we can remove feature y or feature z." This gives them a few choices, and if they insist that you implement both features, tell them it's impossible, and that they should know that as you've already set out the schedule and had them sign off on it.

    As a responsible, professional software engineer, these are things you should be trying to do. If there is resistence to implementing a formal development process, you may have to negotiate a little bit. But ultimately, there is nothing unreasonable about doing business in a formal, well-defined manner. If they refuse to do things this way, make sure you remind them that there will be serious consequences (personally I would threaten to quit the job and work for a more reasonable employer, but that's not for everyone): bad software, missed deadlines, and maintenance hell. This gets you completely off the hook if anything goes wrong. And when things do go wrong, they'll think "he was right", and they'll realize just how good you really are.

    If you want to be a successful software engineer, you need to adopt the attitude that you will NEVER be involved in a failed project (I had the chance to take an excellent course with Marshall Cline, of C++ FAQ fame, and this is one of the things he stressed most heavily and I see a lot of truth in it). You need to take a proactive approach. Take steps to ensure that management is doing things right, rather than simply sitting back and carrying out their instructions without saying a word. Of course, be diplomatic. This is part of a software engineer's job, IMHO. It is things like this that separate the men from the boys in the industry; the true software engineers from the coding monkeys. If you are a software engineer, it's your job to ensure that the company develops the best software possible, or at a more fundamental level, to minimize the time, money, and risk the company expends on the project. Doing that involves more than just coding.

    1. Re:This is largely your own fault by pedro · · Score: 1

      This post is totally correct. We are technologists. We have responsibilities to our ultimate client; The Public.
      We are artists, like it or not. If our employers fail to understand that they are utilising *talent* then they deserve to self-destruct. I have absolutely no mercy for the self - deluded. They should know who they are hiring. If they are hiring the Best, then they know they are taking a risk on OUR economy. The economy of art. We're every bit as reliable as they are, except we're not greedy!
      BUT, if they hang around, we can create wealth. A wealth of art, a wealth of charity, a wealth of, well, Wealth! Well being! For all of us!

      --
      Brak: What's THAT?
      Thundercleese: A light switch.. of TOTAL DEVASTATION!
    2. Re:This is largely your own fault by Anonymous Coward · · Score: 1

      Wow, you have had a much different experience than I have had....

      And when things do go wrong, they'll think "he was right", and they'll realize just how good you really are.

      No. They'll think "he messed it up and didn't do what we wanted" and they'll blame you. Even if you told them what they needed to do, even if you predicted the disaster. It doesn't matter. There are a lot of non-rational human beings out there, and some of them are bosses.

      It is things like this that separate the men from the boys in the industry; the true software engineers from the coding monkeys. If you are a software engineer, it's your job to ensure that the company...

      It's statements like this that seperate the reasonable people from the pretentious assholes. Look, some companies are going to fail, and they are NOT going to let anyone stop them in their headlong plunge into hell. You can warn them, you can threaten them, you can plead with them, and they're STILL going to do it all wrong. The only thing to do is jump ship, and sometimes your personal circumstances won't let you do that. At that point, smile and hang on tight, 'cause the ride gets really bumpy.

    3. Re:This is largely your own fault by Anonymous Coward · · Score: 0

      This is an interesting and beautiful theory (I know because it used to be mine). Unfortunately, it fails in the Real World.

      In the Real World when you threaten to quit over issues your PHB doesn't understand or care about you will be regarded as childish and you will ultimately be fired if you keep it up. After you have been fired a few times you will be regarded as an unemployable trouble maker.

      As to whether or not people will remember that you predicted the disaster: IF they remember they will simply blame you for not averting it. If you then stand up for yourself, you will be decried as a finger-pointer who is not mature enough to shoulder his share of the blame. Comments like "not a team player" and "slow coder" will be made in your personnel record. Eventually you will quit because you will never be promoted.

      "So what?" you say, "I'll just start my own company and show the world how it is done!". Bzzzt! Quality takes time. Time is money. You will be consistently underbid and starve to death before you can even begin to establish a reputation.

      How do I know all this to be true? Twelve years of industry experience with a variety of companies.

    4. Re:This is largely your own fault by Anonymous Coward · · Score: 0

      That's where the part about being diplmatic comes in. Obviously you can't just go to your boss and say "We'll do things this way or I'm quitting". But so long as you use tact, and have decent communications skills, it should be possible to convince them how things should be done.

    5. Re:This is largely your own fault by pedro · · Score: 1

      This isn't so much a response to the previous post as it is a response for me to find to remind me of what the hell I was thinking this fragile night.
      The above post offends me in an EXTREMELY deep way.
      I will not even address this person directly, although I should.
      This (parent) post is the product of fear. (Vanity can work for us here. Perhaps he'll returneth to his own vomit)
      I am absolutely certain that the experiences he describes (vaguely) are his own.
      He has put his fate in the hands of OTHERS. For geeks, this is failure. Geeks are proto-warriors.
      We should comport ourselves as such. If it was not our failure, then the original source of that failure must either be known, or educated.
      Failing that, cast them back into the roiling pit.
      If you are sufficiently convinced of your righteousness, you will be believed.
      SEE: I-CHING.

      I am NOT playing here, people...

      --
      Brak: What's THAT?
      Thundercleese: A light switch.. of TOTAL DEVASTATION!
  68. Re:Fit all code on *one* page - use OO by Anonymous Coward · · Score: 0

    In my experience, if you're developing large-scale software using an object oriented design, it's quite likely that if you designed the system well enough that your typical method will be one or two lines. Very few of your methods will be over 5 lines, and you will rarely need to put comments inside your methods because the code is so simple and obvious. This is the best way of develping software, IMHO, and when I was first exposed to object oriented programming and design patterns, and saw real code written like this, I was overwhelmed at the power of the paradigm.

  69. Posted before by Anonymous Coward · · Score: 0

    these have been posted before, why can't you posters do a search before posting something?

  70. more programming tips from the past by deadl0ck · · Score: 1

    This reminds me of the programming style of Dan Barrett. :) http://www-ccsl.cs.umass.edu/~barrett/bm/Viewer_Se ctions/Articles/77_ProgrammingTips

    --
    --
  71. Even better... by Mr.+Piccolo · · Score: 1

    use INTERCAL. Perhaps the only programming language ever to actually use COME FROM.

    --
    Glückwünsche, haben Sie Slashdot ermordet, indem Sie zum korporativen Druck beugten und Subskriptionen einlei
    1. Re:Even better... by Chainsaw · · Score: 1

      You won't believe the damage you can do with Brainfuck. This got to be one of the most sick and absurd languages ever made. With source code looking more like ASCII art than text, eight reserved signs with no parameters and in general a totally whacky language - you're in for the kill.

      --
      War is one of the most horrible things a human can be exposed to. And one of the worlds largest industries.
  72. Don't you mean FORTRAN? by jcr · · Score: 1

    Remember, FORTRAN is an acronym.

    The last time I dealt with FORTRAN, I ported a massive lump of NASA code called QuickTOP (Quick Trajectory Optimizer) to the mac. I only modified the original code in two places. I let it do its initialization, then it would jump out to the GUI I wrote in Think C. The luser could set up all the mission parameters (what planet he needs to get to, what kind of propulsion is available, etc.) and then jump back into the FORTRAN code to run the sim.

    The punchline is, when I had finished the port, the geriatric NASA guys asked me to translate the GUI code to FORTRAN, to make it... Wait for it...

    ... MORE MAINTAINABLE!

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
    1. Re:Don't you mean FORTRAN? by dgph · · Score: 1

      Don't you mean FORTRAN? Remember, FORTRAN is an acronym.

      Even though it's an acronym, I think it's commonly written as Fortran now. This seems to be a common pattern: the "nameness" of a name becomes more important than its "acronymness" -- hence the capitalized first letter.

  73. Don't you mean FORTRAN? by jcr · · Score: 1

    Remember, FORTRAN is an acronym.

    The last time I dealt with FORTRAN, I ported a massive lump of NASA code called QuickTOP (Quick Trajectory Optimizer) to the mac. I only modified the original code in two places. I let it do its initialization, then it would jump out to the GUI I wrote in Think C. The luser could set up all the mission parameters (what planet he needs to get to, what kind of propulsion is available, etc.) and then jump back into the FORTRAN code to run the sim.

    The punchline is, when I had finished the port, the geriatric NASA guys asked me to translate the GUI code to FORTRAN, to make it... Wait for it...

    ... MORE MAINTAINABLE!

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  74. Be careful, Roedy by osguzzler · · Score: 1

    Interesting article, Roedy, but you ought to be careful because I'm under the impression that a lot of the techniques you mention here have already been patented by a company in the Seattle region.

    --

    Adam:What kept you?
    God:Rome wasn't built in a day
    1. Re:Be careful, Roedy by toriver · · Score: 1

      You cannot possibly be thinking about the publishers of "Writing Solid Code"?

  75. Fortran is easy to understand, BUT . . . by Vlad_the_Inhaler · · Score: 1

    try this:
    ivar = 27
    call sub (27)
    if (ivar .ne. 27) stop 'error'
    .
    .
    .
    subroutine sub (int)
    int = 35
    return
    end

    This delightful bit of coding overwrites the constant 27 with 35. It 'works' under some compilers I have used.

    I actually find most Fortran programs easier to read than C programs. If course you can produce spaghetti with 'go to's but C allows things that have been outlawed by the Geneva Convention.

    --
    Mielipiteet omiani - Opinions personal, facts suspect.
  76. why comment? by Anonymous Coward · · Score: 0

    Programmers know enough of the English language to comment? I guess if it was all abreviations and acronyms they could probably handle it. :)

  77. Re:Fit all code on *one* page - use OO by Anonymous Coward · · Score: 0

    me too. however, i was underwhelmed at the speed and resource usage.

  78. Good for Microsoft. by Inoshiro · · Score: 1

    "The more changes you can make between versions the better, you don't want users to become bored with the same old API or user interface year after year. Finally, if you can make this change without the users noticing, this is better still - it will keep them on their toes, and keep them from becoming complacent."

    From this line, it becomes quite clear that they've started to document some of their common practices. They're not a monoply, they're just following their ISO 9001 certified business standard for programming :-)
    (Proof that ISO certification is just a piece of paper saying people do that they say they do).
    ---

    --
    --
    Internet Explorer (n): Another bug -- that is, a feature that can't be turned off -- in Windows.
  79. It's more insidious than that... by Observer · · Score: 1

    One other very general and very common method:

    Start the implementation before the functionality and overall design are settled and agreed. This guarantees that different parts of the product (preferably the responsibilities of different independent contractors) will be constructed according to different tradeoffs and in extreme cases will be based on mutually inconsistent goals. This can confuse and impede even the rare maintainance programmer who is able to quickly pick up the overall purpose and structure of the product, and the style(s) of writing.

    Note that this method is common in the Real World because it seldom has to be resorted to deliberately: it is a natural consequence of the additional (that is, changed) requirements typically imposed by paying customers in the middle of a project's implementation, or of a budget freeze that means that the first proof-of-concept prototype has to be extended into production rather than being thrown away in favour of doing the job properly, as the original project plan specified.

    Sigh. After 20 years in the business I wish I were joking about this.

  80. moderate this up by daemonchild · · Score: 1


    great post....so true it's scary

    --
    -- Went home. Had to feed the kids.
  81. Want to keep bad code good? by Gordo+Toor · · Score: 1
    1) Create your well maintained code.

    2) Create a search and replace procedure to use in vi!

    3) Whenever you have to maintain the code, reverse your procedure.


    %s/$employeeFirstName/$epfsnm

    in reverse:

    %s/$epfsnm/$employeeFirstName


    4) put comments in an external file! HIDE IT!

    --
    I wrote the play & still own the script ...

  82. IT'S A JOKE!! by 198348726583297634 · · Score: 2
    Geez, it's funny! Laugh! To everyone who wrote, "Well, these are serious reasons why you /should/ write maintainable code," YES! OF COURSE! Of course you should do your best to make your code reusable, modifyable, easy to understand, efficient, etc. but this article was about doing the exact opposite! because IT'S A JOKE!

    Sheesh. :)

    1. Re:IT'S A JOKE!! by Anonymous Coward · · Score: 0

      You can spot the real geeks on slashdot can't you?

      The ones without sense of humour you really have to worry about!

  83. Mirror at http://www.geocities.com by patrixx · · Score: 1

    http://www.geocities.com/TimesSquare/Battlefield/3 691/unmaintain.htm

  84. From a Junior Programmer by drum · · Score: 1
    I believe I'm missing something here;

    Clearly, the first priority is to produce on time. That makes all the sense in the world.

    The second priority - for the products to be operational. So far so good.

    The third, of course, is for all bugs and inefficiencies to be ironed out.

    But shouldn't style come into play at some point? If the situation is code that has been, is being, and will be altered by a variety of people, shouldn't one feel at all obligated to lighten the load for the next guy?

    Paint your car red - fine! But give the next guy the owner's manual, for heaven's sake!

    In my opinion (which admittedly belongs to a lowly Undergrad), professional ethics dictate that the job be done to the utmost - salary and competition be damned!

    1. Re:From a Junior Programmer by Anonymous Coward · · Score: 1

      The program operational is not the first priority?

      Can you really be said to have achieved the deadline if the program is non-operational?

      And I would say that bugs are a result of poor specifications that aren't caught in programming. An exception is only a bug if it isn't handled correctly.

      A program can be bug free if you concentrate on elminating bugs instead of adding features.

      Here is the development cycle:

      1. Produce a stable, working program that performs all the most important features. The framework is set to allow all desired features to be added later.

      2. Add the next highest priority feature. Test and fix all bugs. Repeat 2 until you have added all the features that your users want.

      Making two changes at the same time to code makes finding a bug difficult. Making 50 changes at once makes finding and fixing a bug without adding more bugs literally impossible.


      This is basic systems design:

      It is impossible to develop a complex system from scratch that works. All systems must start as a simple system that works and grow from there.

      Computer languages are an example of this. Languages grow and evolve every year, and the languages and compilers associated with them are nearly bug free. Certainly a compiler is much more complicated (i.e. systems complexity, not lots of features) than most programs. But most programs are full of bugs...

    2. Re:From a Junior Programmer by Anonymous Coward · · Score: 0

      Clearly, the first priority is to produce on time. That makes all the sense in the world.

      The second priority - for the products to be operational. So far so good.


      Usually the first priority is that it work, then that it be on time -- so you have your priorities reversed. However, if the company you're at has a contract saying that something had better be delivered to their ONLY client on such-and-such a day, then it's better to deliver something with bugs (and let the managers fall all over themselves butt-kissing and apologizing for the bugs, with a fix coming out the next week), then not deliver at all and have the company no longer exist.

      The point is, what the priorities are will depend on the situation. There are no hard and fast rules -- adapt or die.

      The third, of course, is for all bugs and inefficiencies to be ironed out.

      This almost never happens in the real world, so don't worry about it. By the time you fix all the bugs in the original set of features, the sales force will have promised new features which you must implement, and they will have bugs. Your life is going to be one long bug-hunt, interrupted from time to time by spec writing. Want to change your major yet?

      But shouldn't style come into play at some point? If the situation is code that has been, is being, and will be altered by a variety of people, shouldn't one feel at all obligated to lighten the load for the next guy?

      Messiness and desperation IS a style after a while. Besides, what you think of as "lightening the load" will probably be viewed by the next guy or gal as a huge stinking load of crap that was a waste of time. If you're in a slow period and want to clean something up, fine go ahead -- but there is no obligation to do so.

      In my opinion (which admittedly belongs to a lowly Undergrad), professional ethics dictate that the job be done to the utmost - salary and competition be damned!

      Ah, but what is the job? The company views you as a resource... at best, to be sucked dry of all useful energy, and then they throw away your drained husk and get the next guy. If you think you work for the company, then you're ripe for being used. Everyone works for themselves. Even if you are employed somewhere, think of yourself as a private contractor... because the company sure sees you as a temp worker. You work for you, period. Your job is to work for bucks, which are then used to help fulfill your own life goals, whatever they may be. If your goals are in concert with the company's goals, great! If not, too damn bad for the company -- screw 'em. After all, they'd screw you (and if you wait long enough, they will).



    3. Re:From a Junior Programmer by Anonymous Coward · · Score: 0

      Style... Damn straight it's all about the style, and some guys just can't dig that funky jazz that is my coding. If you ain't hip enough to what part of my code does what, you're just a square, man.

    4. Re:From a Junior Programmer by ushirageri · · Score: 1

      "I believe I'm missing something here;" You certainly are. Try a sense of humour! But... having worked, in the past, as a grunt programmer, nothing brought a bigger grin to my face than presenting a piece of code to my supervisor(Who was not a programmer) and watching his eyes glaze over, his face contort and his brain go into neutral. All this was after he suggested that a high school co-op student could revise my code. Evil? Most certainly. Gratifying? Immeasurably! Don't screw with a geek!

    5. Re:From a Junior Programmer by trog · · Score: 1

      I may be a square, but I'm a senior-level, six-figure a year senior unix geek GOD. Bow down, child.

      I'll be retired before you even finish puberty.

  85. programming language and clarity by sohp · · Score: 2
    The most interesting line of comments that has popped up is the one associating unmaintainable code with specific languages. Notice though that the article specifically mentions Java, which is among the clearest languages today (though not without its faults).

    What differentiates maintainable code from spaghetti code is not just whether or not the syntax of the language allows for obfuscated code, or if all of the variables and functions are documented and clearly named, if some code conventions are followed or if it has been run through a beautifier, but whether the code was written with a clearly thought-out and documented design.

    If the programmer has actually taken the time to think about the data structures, the algorithms, and the classes(or program sections if you aren't using an OO language), then the code becomes truly understandable. This is not to say that you can then ignore good programming techniques -- they are still necessary -- but that documenting every function, variable and data structure in a program that is otherwise a crufty mess is pretty much a waste of effort. Try it sometime -- look at the source code for Perl, and have the perlguts man page and Gisle Aas's wonderful illustrated guide to Perl's internals handy, and you'll get the idea.

    I've seen code in lots of languages that would be considered 'maintainable' if all it took was strictly following a convention, but in fact was frustratingly difficult to maintain because the programmer didn't have a clear design for the system.

  86. Only because you asked: by Anonymous Coward · · Score: 0

    A master was explaining the nature of Tao to one of his novices. "The Tao is embodied in all software -- regardless of how insignificant," said the master.

    "Is Tao in a hand-held calculator?" asked the novice.

    "It is," came the reply.

    "Is the Tao in a video game?" continued the novice.

    "It is even in a video game," said the master.

    "And is the Tao in the DOS for a personal computer?"

    The master coughed and shifted his position slightly. "The lesson is over for today," he said.

    -- "The Tao of Programming"

  87. How to... use MS VB!!! by Anonymous Coward · · Score: 0

    bloody horrible piece of turd it is...

  88. another war story by CormacJ · · Score: 1

    It fell to me to maintain a helpdesk system that a director of the company had written.

    This guy wrote about 20,000 lines of code and all the variables were variations on the letter "t", eg t, tt, ttt, t1, tt1, t1t, etc.

    He had the mistaken belief that he was a hotshot programmer. The rest of the real programmers knew that he was a clueless idiot.

    In one report he had the calculation: ttt=t1+t2-((tt1*ttt1)/tt)+tttt1

    He was very keen on squeezing as much code onto one line as he could too.

    It took me 3 weeks to amend one report so that 1 extra item from the customer database could be displayed.

    After this I wrote a suite of tools to reformat the guys code so that it was understandable, and pointed out the errors that he'd made. The same company director later made a small fortune selling my tools to the company that provided the database engine. I think that was his revenge.

    I also knew one programmer that wrote an RPG system without using arrays, because he didn't realise you could do that sort of thing. Last I heard of him he was an engineer for Compaq.

  89. if else if else if else if else if else if ... by Get+Behind+the+Mule · · Score: 3
    Some of my favorites, all of them true stories about code I had to maintain:
    • If your program executes one of many different unrelated functions on each run, don't use any of them steenkin' Commie pinko data structures like a dispatcher table, and for Pete's sake don't split the various functions into different source files. Put it all into one enormous if ... else if ... else if ... statement that extends across 10,000 lines. Hey, if they want to change a line of your code, they better be sure that the whole thing still compiles.
    • If you must break up functionality into subroutines, use global variables with reckless abandon!
    • Whitespace slows down your compiler or your interpreter! So cram that code into as few characters as possible! (I had a colleague who really believed this.)
    • Are you worried that upgrades to system libraries will break existing programs? No problem, just install them on some non-standard path, like in your home directory, and link them in from there. You don't need to tell your colleagues where to find them, because surely you'll get around to re-installing them in the right place Real Soon Now.
      Say you're programming CGIs in Perl using modules. Whatever you do, don't install new modules in the system-wide site library, because that could cause all kinds of trouble! Better to put them all in /cgi-bin/lib/ and use use lib '../lib'; to bind them in. But what if you have test scripts in /cgi-bin/test/? No problem, just install the same modules all over again into /cgi-bin/test/lib/ (don't be too picky about whether you're using the same module versions). And if you have mod_perl registry scripts under /perl/, then install all those suckers under /perl/lib/ and under /perl/lib/test/ all over again! So what if you end up with four different versions of the same modules, at least you didn't take any chances the system-wide installation.
    1. Re:if else if else if else if else if else if ... by Quarnage · · Score: 1

      I just have to add the most egregious code I have ever worked on was the main processing loop in a touchscreen driven system. The main bulk of the code consised of one LARGE switch statement with approximately 200 cases. The labels on these cases were simply the decimal integer corresponding to the ascii character the original developer typed to test the software originally with additional codes added later as it grew. Many of the cases could have been fully functional modules in their own right. One case even had another nested switch statement with an additional 60 cases. As if this wasn't bad enough, this routine tended to re-invoke itself recursively. If I am ever going to engineer my job security I will always follow this example ;)

      --
      http://www.crispypix.com
      CrispyPix enhances images right in your browser!
  90. Special characters by Tycho · · Score: 1

    I don't think anyone else has suggested this, but to make you program even more unmaintainable use special characters.
    For instance MrC on a Mac will allow you to use one special character instead of two like opt-equal for not equal, opt-comma for less than or equal, or opt-period for greater than or equal. Now if you were to use this randomly, if someone else ever tried to port the program to a different platform using a compiler that didn't support these characters, it would be unpleasent to say the least. If you've done your job a maintainer would have to look at a bizzare character and guess what the correct symbol would be. Of course eventually a maintainer could figure out what character meant what. Even better depending on how the program was translated the symbol for less than or equal could be turned into just less than, making for a fun time debugging when things hit boundry conditions.

    --
    Impersonating Tycho from Penny Arcade since before there was a PA.
  91. Unreadable? Ttry Befunge for a laugh! by Anonymous Coward · · Score: 0

    Nice two-dimensional language...
    http://www.meta.demon.co.uk//zbefunge.html
    from : http://users.ox.ac.uk/~univ0938/2dpl.html

    Enjoy.

    1. Re:Unreadable? Ttry Befunge for a laugh! by Anonymous Coward · · Score: 0

      Bah, befunge is for wimps... Real Men use trifunge, or even higher dimensional versions...

  92. Programming tips by MaxAttack · · Score: 1

    SO it looks like Microsoft decided to leak some of its coding secrets to the public.. At least there helping :),

  93. Re:Fit all code on *one* page - use OO by CryptdotX · · Score: 1

    Ah, don't forget the joy of trying to understand a set of several dozen objects when a procedure with maybe a couple of loops and arrays would suffice.

  94. 30,000 lines of BASIC... by Anonymous Coward · · Score: 0

    I've just got to leap in here.

    We had a 30,000 line BASIC program that had been converted automatically to C - filled with "goto 3700" and "for (i_int=1;i_int

    To cut a long story short, the company eventually went bankrupt.

  95. java code by rent · · Score: 1
    39. In Java, disdain the interface. If your supervisors complain, tell them that Java interfaces force you to "cut-and-paste" code between different classes that implement the same interface the same way, and they know how hard that would be to maintain. Instead, do as the Java AWT designers did - put lots of functionality in your classes that can only be used by classes that inherit from them, and use lots of "instanceof" checks in your methods. This way, if someone wants to reuse your code, they have to extend your classes. If they want to reuse your code from two different classes - tough luck, they can't extend both of them at once!

    I think the AWT designers probably had a good reason for designing the code that way..I'm not sure, but I'm guessing is that the classes used by the AWT are 'heavyweight' components that are provided by the OS, which might have restrictions on subclassing. Also Java does not support multiple inheritance, so inheriting from more than one class would be impossible..

    The page was a Good read anyways! :)

  96. arrays and why they are useful by Harri · · Score: 1

    I saw some code once that went something like:

    int one;
    int two;
    int three;
    ...
    int thirty;
    ...
    ...
    one = big_long_math_expression_with_1_in;
    two= same_big_long_expression_only_with_2_instead;
    ...

    and on in the same vein for many pages. I don't remember what the code was meant to do, but it did it! I really really hope that the guy who wrote it knew about those nifty cut and paste things though.

  97. There's one more by Tharsis · · Score: 2

    Interleave your code with as much trace code and printfs as possible. This way even the expert maintainer really can't figure out what statement does something useful.

    1. Re:There's one more by ucblockhead · · Score: 1

      And don't forget to make sure that those traces are in tight loops so that if you attempt to add your own you are greeted with the following:

      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      in loop
      (repeated 100 times more each second)

      --
      The cake is a pie
  98. Or by Anonymous Coward · · Score: 1

    You could have replaced variable names with the names of your girlfriends. Saw that once in an accounting program. And subroutine names were their measurements and "attributes." Like moaner, shaker, twitcher, gasper.

    Just hilarious. It's a great life if you don't have to sort out something like this.

  99. Stupidity from Outer Sp^H^H^H^H^H^H^H^HReal Life by Cactus · · Score: 1
    How's that?

    label.set(selected->description);

    title.set(selected->name);

    description.set(selected->title);

    --

    Guikachu: Resource editor for PalmOS developers

  100. Re:Fit all code on *one* page - use OO by Anonymous Coward · · Score: 0
    Ah, don't forget the joy of trying to understand a set of several dozen objects when a procedure with maybe a couple of loops and arrays would suffice.

    Sure, this is #5:

    5.In the interests of efficiency, avoid encapsulation. Callers of a method need all the external clues they can get to remind them how the method works inside.

  101. This is OLD! by gabrieltss · · Score: 1

    This is an OLD item. I had seen this over a year ago.

    Nothing new here. Come on guys lets put up CURRENT stuff. Not sutf that is over a YEAR old.

    --
    The Truth is a Virus!!!
  102. RPG - How could I forget... by gwicks · · Score: 1

    My first *real* job was maintaining an inventory control system, on an IBM System/36, written in RPG.

    In German!

    It was bad enought that any comments were in German, and all accounting terms (stock on hand, out of order, balance) but RPG limited you to 6 or 8 character variable names. And it was someones bright idea that the first two characters were used to identify the program.
    Then they used acroymns. Examples include GBKXA1 (always uppercase).

    Above all that, RPG used indicators. These true/false 'flags' could be used to condition code, and 3 of these indicators could be concatenated on a single line.

    Then you can set the indicators by placing it in columns from 60 to 65 (if I remember) based on the result field being zero, positive or negative.

    Even better was the commenting function. RPG was (is) strictly column based. Place a * in column six and the line is a comment. How many times, when trying to work out what a program function was doing did I find that the code was in fact commented out.

    Missing rule? Carefully hide open and close comment tags in the code


    I was a good start to learn *what not to do* and the other guy's in the team taught me the basic's of maintanable code. Thankfully, I've forgotten most of it by now and work in the internet world where it seems obligatory to code in the most obtuse way as possible!!

    --
    All spelling mistakes are in my mind and are faithfully reproduced by my fingers
  103. Correction for rule 27 by Gothmog · · Score: 1
    unless the type's of i and myArray are the same size,
    myArray[i]is not equivilent to i[myArray]

    If they aren't, here is the proper conversion:
    myArray[i] is equivilent to (i[myArray/sizeof(myArray)]+myArray%sizeof(i))

    I think that is correct, correct me if I'm wrong.

    I love C.

    1. Re:Correction for rule 27 by dutky · · Score: 1
      Um, no.

      The orriginal statement was correct. Due to the way that C implements array indexing, you can write either array[index] or index[array] and it will work just fine. Your conversion is confused on several points:

      1. array and index will almost never be of the same size since one is a pointer type and the other is an integer type.
      2. The expression array/sizeof(array)+array%sizeof(index) is undefined because division (and possibly modulo remainder) is not defined for pointer types.

      Of course the less maintainable version of array indexing is the pointer arithmetic form:
      array[index] goes to
      (array+index) or even
      (((char*)array)+(index*sizeof(array_type)))
      While you're at it, you may want to throw in an extra array_type pointer to act as a temporary pointing to the currently indexed element. Then it will look as if the pointer arithmetic is really doing some usefull work!

      BTW, this equivalence between pointer arithmetic and array indexing is the reason that you can transpose the array and the index above.
  104. Ahh, but you forget Scott Adams by Mark+F.+Komarinski · · Score: 2

    "Don't be irreplacable. If you can't be replaced, you can't be promoted."

    This works. Trust me.

    --
    -- Ever notice that fast-burning fuse looks exactly the same as slow-burning fuse? I didn't... (Edgar Montrose)
    1. Re:Ahh, but you forget Scott Adams by ucblockhead · · Score: 1

      I had to quit my last job because of this.

      My boss couldn't understand why I wanted to leave after being told that they wouldn't "bother me" with project leadership tasks on the new, high-profile Windows NT, COM+ project so I could have more time to maintain a ten year old poorly written OS/2 system that was being phased out. (I was the only one who understood it.)

      --
      The cake is a pie
  105. thief by hawk · · Score: 1

    If we take out your fancy dance around the subject, it becomes much simpler:

    You're a thief.

    You also deliberately sabatoged your employer's property. But, just like so many other criminals, you justify it to yourself with that babble.

    1. Re:thief by Anonymous Coward · · Score: 0

      not at all, he hasn't taken anything, he just hasn't given everything and it seems to me he was within his rights not to.

    2. Re:thief by Samrobb · · Score: 1

      You know, I'd agree with you except for one statement he made:

      I was working in a PC Support role at the time and there was no mention of programming in my contract.

      They asked him to do something that he was not contractually obligated to do, that he was not being paid to do, and he did it anyways... and he's a thief? From the looks of it, the company was the thief - they were trying to do an end-run around a contract and receive extra value above and beyond what they were willing to pay for.

      He might have had a different attitude if they had told him that doing a good job could lead to a change in position, reworking of his contract, or that there was some other kind of possible future compensation for doing something that he was not hired and not being paid to do.

      As it stands, the company essentially tried to get something for nothing. He gave them something which was certainly less than what they might have potentially gained - which was surely more than what they paid for.

      --
      "Great men are not always wise: neither do the aged understand judgement." Job 32:9
    3. Re:thief by coyote-san · · Score: 1

      As I see it, he had two legitimate choices:

      1) Insist on the terms of the contract and refuse to code. If he was idle because the company didn't provide a designated programmer, well that was their problem. (They are the ones who identified the job duties in the contract, after all.)

      2) Write code even though he wasn't contractually obligated to do so... and act like a professional programmer. That means meaningful names and comments.

      Instead, he choose a third option: write the code, then hide the details. Then harbor fantasies that they would bring him back in a "contract rates" for maintenance.

      Here's a clue: he just had his interview as a "real" programmer, and he failed it with absolute prejudice. (That means that not only does he not get the job today, I'ld tell HR to add his name to the "*never* hire, with cause" pile.) He obviously didn't think through the consequences of his actions: when a bug occurs in his code his employer could never know if it was an honest mistake or an attempt to *extort* money for additional services. The use of a criminal term is intentional.

      --
      For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
    4. Re:thief by hawk · · Score: 2

      >They asked him to do something that he was not
      >contractually obligated to do, that he was
      >not being paid to do, and he did it anyways...
      >and he's a thief?

      No, he wasn't contractually obligated--at the time he was asked. Once he began the work, it modified the contract (more technically: the company offered a contract modification, and he accepted it by performance).

      Once he undertook the duty, he was obligated to due so correctly.

      The company did *not* try to get something for nothing. They requested a service at the rate he was already receiving. He took the money to do so. And stole the work that he was paid to perform.

      [overrated? at a default? hmm . . .]

    5. Re:thief by Samrobb · · Score: 1

      Even if he did implicitly agree to a contract modification (he may have; IANL, and the law has stranger things in it...) - did he also implicitly enter into an assumed modification that assigned intellectual property of his creation to the company? If not, and there was no such assignment in his original contract, then he owned the code, and was free to do with it as he wished.



      Once he undertook the duty, he was obligated to due so correctly.



      Legally, or morally? Morally, I'd agree with you... if he made the commitment, I think he should have followed through. Legally, though, I don't think there was a commitment, and he can't be held accountable for not doing work he was never hired to do.

      --
      "Great men are not always wise: neither do the aged understand judgement." Job 32:9
    6. Re:thief by hawk · · Score: 2

      >Even if he did implicitly agree to a contract
      >modification

      Actually, it's explicit: the modified contract is accepted by performing the action

      >(he may have; IANL,

      but I am :)

      >and the law has stranger things in it...)

      nothing strange here; this is no different as a legal principal than working eight hours instead of the six in your contract, and expecting an extra two hours pay.


      >- did he also implicitly enter into an assumed
      >modification that assigned intellectual property
      >of his creation to the company?

      It was work for hire. The employer is entitled to all of it.

      >If not, and there was no such assignment in his
      >original contract, then he owned the code, and >was free to do with it as he wished.

      If for some reason there wasn't, he was stealing when he did it during time the company was paying him . . .


      >Once he undertook the duty, he was obligated to
      >due so correctly.

      >Legally, or morally?

      Legally.

      >Morally, I'd agree with
      >you... if he made the commitment, I think he
      >should have followed through. Legally, though, I
      >don't think there was a commitment, and
      >he can't be held accountable for not doing work >he was never hired to do.

      He was doing it on company time, for which he was paid. He then vandalized, it, and took the copy he wasn't entitled to.

    7. Re:thief by mudslide · · Score: 1

      As he originally said, the company has the source, just not readible source.

      What was stolen?

      --
      -Jess
    8. Re:thief by GC · · Score: 2

      Thanks for the discussion. I have to add that I was asked to produce something which would perform the tasks required. This involved coding, but the manager who actually set me the task did not know enought to know that it was an actual program that was required. They have a working system and that was what I was asked to produce. I don't believe I am a thief and all parties involved are happy with what they have got out of it. Perhaps: A victimless crime?

      Shall I go to a police station and confess?

      Also note I was employed in the UK and you cannot apply US employment law to my case.

      Some of the comments in this thread are actually quite surprising to me. There is the air that every employee should always bow their heads to their managers and never do things for themselves. There also seems to be the opinion that everyone should be selfless and not look out for number one.

      I confess, I don't believe in this ethos. At the end of the day all I care about is myself and those that care about me, the rest are immaterial, but they needn't go to hell.

      I did do other coding in this employment and did not alter the code, leaving explanatory comments and even writing a 40 page manual of how the system worked and both user and programmer references. In all the time I was employed there my salary rose by only 3% (OVER TWO YEARS). PC Support Analyst to Developer?

      And it seems I still am judged by my peers as a thief, the devil incarnate perhaps?

      Oh well, lets leave this one to the archives of /.

    9. Re:thief by Zurk · · Score: 1

      oh bullshit. *all* the contractors i know do exactly the same damn thing and no one blacklists them. what you said is detached from reality. do you smoke crack ?

  106. IOCCC by Captain+Zion · · Score: 1

    I'm surprised I didn't see it in the previous comments (or perhaps I just missed it), but most of the obfuscation techinques mentioned above have been used in the IOCCC and commented in Don Libes' Obfuscated C and Other Mysteries (the book is currently out of print). I highly recommend it! :)

  107. Au Contraire by Anonymous Coward · · Score: 0

    If you work in the realm of Internet development where development cycles are very short (a few weeks), IMHO you *have to* be thinking about the clarity amd maintainability of your code because usually you are not the only one who will touch that code. I just finished a project was a rewrite of an existing dynamic section of a website that took me two weeks to do. Most of the time was spent trying to understand the hacks on top of hacks on top of legacy code. (I'm talking about code that's 3 months old) This was a very frustrating experience. In a rapid devlopment environment a clear methodology is extremely helpful to avoiding the hours of ramp-up time that's necessary for someone who doesn't know your code to modify or add to it. -K

  108. bad code == bad program by jsno · · Score: 1

    This article is a good tongue-in-cheek bit of humour, and i love a laugh, but i sensed that it was a little bit more than this.

    When i was a kid learning basic, and was new to programming (12 years ago), i had this mentality. The mentality quickly dropped when i started having to maintain and design real projects. I very quickly learnt that there's nothing clever in making code that's hard to read.

    My goals have always been development time, and execution efficiently. I've found that it's very easy to write a program that's fast and easy to read. If a piece of code is easy to read, then it's easy to debug. If you are wasting energies on making code that's hard to read, then it can't be good code, and therefore a good program. If it's not a good program, then how is that going to make you look as a programmer?. How does this improve your job security?.

    In my experience, fantasies like these are often shared by newbies, or people who aren't very good at it. If this article has inspired you to become a "bush mechanic" style coder, then you shouldn't be in the game. You'd be better leaving the field and giving somebody else who is more gifted than you a go.

  109. Maintenance Programmers [sic] by Tom+Christiansen · · Score: 2
    Don't forget that you should always hire Fortran programmers to maintain your C++ code, Aural Basic programmers to maintain your Perl code, and Cobol programmers to maintain your Java code.

    Why? Because that's what everyone's doing, at which point they bitch and moan about how their Fortran, Basic, and Cobol programmers can't understand the C++, Perl, and Java code you've written.

    Funny thing.

    They sometimes even have the unbridled audacity and incredible stupidity to demand that you convert your code to look like the languages that the "maintenance programmers" understand. I've never come up with a better answer than to suggest that people run very far, very fast from this all to prevalent mentality. The world is a strange place.

  110. Perl-impaired consultants by Q*bert · · Score: 2
    Maybe they were deliberately goldbricking to extract more hourly pay from your employer! This is yet another danger of ignorance and prejudice. If your only conception of Unix is that it's "bad juju", it's easy for unscrupulous people to take advantage of you.

    Vovida, OS VoIP
    Beer recipe: free! #Source
    Cold pints: $2 #Product

  111. Some terse advice (if you don't decide to quit) by Q*bert · · Score: 2
    Rewrite with extreme prejudice.

    Vovida, OS VoIP
    Beer recipe: free! #Source
    Cold pints: $2 #Product

  112. Taken Way too Seriously by n1ghtstr1k3 · · Score: 1

    I think people are taking this way too seriously. Seems to me to be just a light-hearted look at programming, with much sarcasm, not actual advice on how to keep your job.

  113. Maintainable Code - Oxymoron for Managers by MikeTheMad · · Score: 1

    Maintainable code, aah, what exactly constitutes maintainable code?? Let us ponder, to those of use writing "C", we all "think" we know what this is, but, do we as programmers really ever think about this unless we are under the gun to figure out why this bit was flipped? Most of the really good programmers I have worked with don't write complex or unmaintainable code on purpose, this usually happens because we as a group are pretty lazy. Why write 10 lines of code when you can write 1 or two ? Perception also figures into this. For my money, there is no unmaintable code. Any good programmer can figure out whatever he/she wants, "what's printf/display for anyway". Now, before I get flamed, let me say that I have seen poor code, but - this is usually a factor of education, not intention. I usually hear this complaint from newbies/converts who suddenly find out that the computing world is complex and they may have to actually think for themselves. Ask yourself, are you complaining because this is a pain in the "xss" or because you don't know how to fix/implement your problem. If it's door number one, hey ding dong, your getting paid big bucks ain't ya?? Or door number two - shutup and learn you whiner!!

    --
    Confusion to the Masses
  114. Obfuscating without appearing to. by hey! · · Score: 2

    Most obviously obfuscated code is produced by relative newbies who don't know what all the features of a language are for (e.g. case conditionals implemented as loops etc.) It never looks professional to code this way.

    And, after you've seen a few thousand modules done this way, you can pretty much burn through them; it's actually kind of fun, like doing a puzzle.

    The evil done by obfuscated code is nothing compared to the evil done by obfuscated architectures. Any power you give somebody can be used for good or evil, and the power you have when designing in architectural dimensions (like class hierarchies or APIs) is both greater and more subtle. Example: DDE. Real world projects include not only bits of code, but class hierarchies, databases, file formats, external interfaces etc. You can write code as limpidly as Kernighan and Ritchie, but still end up with a system that is totally unmaintainable by anybody but you. Furthermore, it will be utterly unclear to anyone whether this was deliberate, or caused by technical constraints (i.e. things you must interface with), or is somehow tied up in the nature of the problem.

    Write overly complicated code, and people will think you're an idiot. Design overly complicated systems and write beautiful code to solve the unnecessary problems you create, and they'll think you're a genius.

    --
    Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
  115. Design by Hard_Code · · Score: 2

    Well I'm scared because I don't know if that is sarcasm or not. I guess I'm an idealist. I like to /design/ systems. Coding is just what you have to do to make your design concrete. A lot of people don't think this way. They think the code is the end, not the means. And hence you get nasty messy complex weak broken sorry ass systems and you need more people to support them than if you actually designed it correctly the first time. Sometimes I have to work on a project and I have to hold myself back from slapping everybody and starting from the ground up...I just have to grit my teeth and get my hands dirty so I can fix the a symptom of a much larger problem. Computing is truly going to hell if the above was /not/ satire...

    --

    It's 10 PM. Do you know if you're un-American?
    1. Re:Design by Anonymous Coward · · Score: 0
      I would like to have the opportunity to design things more often... however, this is usually the way I've seen it work: management wants something "demoed". often, they can barely define the "something". A quick hack that appears to do 65% of the things some developer(s) think the "real product" might do is produced. management assumes the "demo" is the "product" and that things will soon really be ready for customers. developers are asked to continue developing at full speed, assuming they naively are just "enhancing the demo" and not "finishing the product."

      A few weeks/months/whatever later, the demo looks good. Management thinks they have a product. The developers are in trouble cause the "hack" has grown out of control.

      i find that this thought process is usually the result of incompetent management that doesn't understand the difference between the "quick hack" and "doing it right". Of course, it doesn't really bother me that much, as long as I'm having fun. If the stuff gets too messy and I'm not enjoying myself anymore, I'll just find another job...

  116. I remember the good old days... by handorf · · Score: 2

    My previous employer had a HUGE Dos system.

    Started in BASIC, went through an interpereter to C and still had bits of assembler for certian bits. Wow, this code SUCKED.

    I didn't have much to do with it, but I did have to emulate some things it was doing in a new Windows system (ewww).

    The best part was when I found out that 'S' was a global void *. Depending on the part of the program it was used for a half a dozen different types. The structured programmer in me had spazmotic fits, but I couldn't have the programmer killed cause he was the owner of the company.

    Oh, there was also a global 's' which was declared as an int but used as a void *.

    Oh well, back to my stupid Access project. How can anyone work in a language without pointers? :-)
    -- I'm omnipotent, I just don't care.

    --
    -- IANAEG - I am not an elder god.
  117. My first job by jabber · · Score: 2

    My first job experience was to help port some old Fortran code, from a mainframe to a workstation, and from Fortran-77 to Fortran-90. There were revisions and comments dating back to 1983 (this was in 96-97)... (Aside: There's an age/revision level past which code should NOT be maintained, it should be rewritten)

    All in all it was a great learning experience. I've developed an aversion to spaghetti since then.

    Imagine if you will, a 2000+ line subroutine containing many a multi-level if-else/for-do construct, from the depths of which conditional computed GOTO statements jumped into the middle of another multi-level for-do/if-else loop. Intercal was never more fun.

    The true kick of the experience was that it was to be a code port. Not a rewrite. Not even a little. A straight port, so the original developers wouldn't have to figure out any new logic. Feh!

    --

    -- What you do today will cost you a day of your life.
  118. Re:How to... use MS VB!!! - True, but.. by Anonymous Coward · · Score: 0

    You're correct. Use VB if you want unmaintainable code. But use Perl if you want _completely_ unmaintainable, horrible looking code.

  119. Good globals by ucblockhead · · Score: 1
    And don't forget to use global variables to pass data to functions. (Parameters are so passe). And to save space, name them 'i', 'j' and 'k'. But don't worry, you can still declare a local 'i' for loops as long as you don't need the global one.

    (Don't laugh. I found this in real code. I found this in real code that had been cloned into 30 different files.)

    In naming functions, make heavy use of abstract words like it, everything, data, handle, stuff, do, routine, perform and the digits e.g. routineX48, PerformDataFunction, DoIt, HandleStuff and do_args_method.

    Oh, and a great way to avoid long functions is to break them apart like this:


    DoIt()
    {
    /* Stuff */
    DoIt2()
    }
    DoIt2()
    {
    /* Stuff */
    DoIt3()
    }
    DoIt3()
    {
    /*Stuff*/
    }


    (more real code.)
    --
    The cake is a pie
  120. Make it stop ! by Anonymous Coward · · Score: 0
    I've been fixing other peoples bad code for over 10 years.

    For god's sake, learn some lessons about maintanability.

  121. Another important rule -- language choice by Rob+Riggs · · Score: 1

    Always use the least appropriate language for the job at hand. Use C or C++ for parsing simple text files. Write huge applications in Perl. Use Bourne shell script to create a GUI framework. The opportunities for turning a small programming project into a lifelong commitment are endless here.

    Another axiom to this rule is learn an obscure general purpose language and write everything in that. Your employers will have such a hard time finding experienced help, you should be able to demand a daily salary increase.


    --
    the growth in cynicism and rebellion has not been without cause
  122. Absolutely! by Anonymous Coward · · Score: 0

    If you can rewrite this kind of tough-math-intensive software, you'll become both a hero and a legend.

  123. From a not-so-junior programmer by Anonymous Coward · · Score: 0
    My beef with junior programmers is that they start to implement something, then they say "oh, no, this is the wrong way to do it" and start fiddling with the specs and interfaces so they can implement it another way. And nothing gets done, no product gets out the door, no big bonus check gets into my pocket, so before that I happens I have to go to them and tell them "stick with the first way and get the product out the door, then we'll talk." Which they don't like, they say "It's ugly!" but so what if it works?

    I'm working on a project now where I see a much better way to do something than what I wrote up in the design spec. But I'm changing the design spec only slightly, and that in order to simplify my portion of the code in order to get the product out the door earlier (albeit at the cost of making cross-platform ports a bit harder), not to fix the ugliness.

    - Been there, done that...

  124. Clearest thinking I've ever seen. by DevilEye · · Score: 1
    Ah, but what is the job? The company views you as a resource... at best, to be sucked dry of all useful energy, and then they throw away your drained husk and get the next guy. If you think you work for the company, then you're ripe for being used. Everyone works for themselves. Even if you are employed somewhere, think of yourself as a private contractor... because the company sure sees you as a temp worker. You work for you, period. Your job is to work for bucks, which are then used to help fulfill your own life goals, whatever they may be. If your goals are in concert with the company's goals, great! If not, too damn bad for the company -- screw 'em. After all, they'd screw you (and if you wait long enough, they will).

    Damn right. This is why the smart 'uns go into the consulting biz.

    --
    When you're crushing a man's windpipe with your knee, you can be sure he will attempt to bite you.
  125. My wee horror story by Anonymous Coward · · Score: 0

    In ANSI C, build your program around one core function that takes at least 17 arguments (Do Not use a structure). Do Not provide a prototype in the header file. Insert (not append) at least 3 arguments each time you upgrade the library.

    I was on the receiving end of that library. I won't tell you where, just consider every completed telephone circuit a miracle.

  126. Duff's device by Fjord · · Score: 1

    The UNROLL macro you show there is a loop unroll like "Duff's Device". I'll explain why you'd want to do this while I talk about Duff's incarnation (because it's related but more interesting :).

    Duff's Device was a contruct created by Tom Duff as a way of manually unrolling a for loop in a highly optimal way. The story goes that he was writing a multimedia application and noticed through profiling that he was spending a lot of time in his tight loops. In these loops he was doing a simple operation (copying from a buffer to a port).

    The problem was that for each copy, he would do a compare. so he came up with this code (Tom Duff is a professional and is it not recommended you try this at home):
    send(to, from, count)
    register short *to, *from;
    register count;
    {
    register n=(count+7)/8;
    switch(count%8){
    case 0:do{*to = *from++;
    case 7:*to = *from++;
    case 6:*to = *from++;
    case 5:*to = *from++;
    case 4:*to = *from++;
    case 3:*to = *from++;
    case 2:*to = *from++;
    case 1:*to = *from++;
    }while(--n>0);
    }
    }
    Yes it compiles. 7 compares are removed.

    Modern optimizers have learned from Mr. Duff and will unroll loops for you (if you choose speed over size), so you no longer have to subject people to this kind of heinousness. It is notable though that the TIFF code does an op1 to every 8 times, so this construct may not be removable from the code where op1 isn't NOP.

    For Tom Duff's commentary on Duff's Device, Go here

    --
    -no broken link
    1. Re:Duff's device by Abigail-II · · Score: 1

      Perl lets you use that trick in combination with computed GOTO, and bare blocks that are really loops.

      #!/opt/perl/bin/perl -w

      use strict;
      my $count = shift;
      my $weeks = int (($count + 6) / 7);

      goto "DAY${\($count % 7)}";

      {
      DAY0: print "Sunday\n";
      DAY6: print "Monday\n";
      DAY5: print "Tuesday\n";
      DAY4: print "Wednesday\n";
      DAY3: print "Thursday\n";
      DAY2: print "Friday\n";
      DAY1: print "Saturday\n";
      redo if -- $weeks > 0;
      }


      -- Abigail

  127. not ./ing but browserism by Anonymous Coward · · Score: 0

    Some have claimed difficulty viewing this site and speculated on ./ism... it may be browserism and anticacheism. It will serve to kfm, Arena, lynx, and curl but sends my Quill empty content. And they all went through the same Squid.

  128. Re:Hungarian notation by Arandir · · Score: 2

    I think you've missed the whole point of Hungarian notation. Those examples you used were quite contrived (and if they did actually exist in code, it is the coder's errror, not the convention).

    HN is a good way to indicate the kind of variable, and it does not preclude meaningfull name. What is maxTypeCode? A string? An int pointer? Pointer to a user defined type? I don't know without scrolling back up to the declaration. is numLinePayments a signed or unsigned int? On the other hand, pszMaxTypeCode tells me instantly that it's a string and iNumLinePayments is signed.

    Likewise, your iNmPt example illustrates braindead programmers, not the shortcomings of HN. It should have been called iNumLinePayments.

    I think too many unix coders are frightened off from HN simply because it came from Microsoft. Don't be. Try out HN, and if you don't like it properly used, then don't use it.

    --
    A Government Is a Body of People, Usually Notably Ungoverned
  129. nope, HTTP bug by Anonymous Coward · · Score: 0

    Ha... found it. Quill sends a content-length header in the request, and the server thinks it's meant to limit the reply content. As I read HTTP/1.1, that's incorrect (and sending it with a GET may be incorrect, too. Bleah.)

    Someone better tell Novell? Anyway, that's unlikely to be the cause of others' troubles.

  130. Marklar! by fizbin · · Score: 1

    void markle(MARKLAR marklar) {
    MARKLAR* Marklar;

    Marklar =
    Markle(Marklar);
    }

    /* This takes the marklar, creates a marklar to it and then just uses Markle on the marklar that points to the marklar.*/

  131. Prof. Bruce here again. The TA has been fired. by Anonymous Coward · · Score: 0
    Another lousy paper into the thesis/dissertation bin along with another grad student who will never see a professorship nor a position in industry. Man, that thing's full too. Gotta empty it. Where do we get these TAs anyway? They must be drawn from the pool of grad students who couldn't hold the internships in the real world. *sigh* Time for his advisor to do him a favor. There, that ought to do it... Oh, welcome back class, I didn't see the 3% of you that came back come in. Have a seat. There's plenty of room now. Your other classmates have all jumped over to liberal arts majors. Wimps. Now, let's debunk some more drivel from la-la land. Batter up!

    The first mistake I'd like to clear up, is the class title. Just because a programmer codes cleanly is no indication that his spirit has been broken. In fifteen years of programming (that's after Uni), I've noticed that source code is a fairly good indication of thought process. If the code is badly laid out or badly commented, it's a good bet the programmer didn't know what was going on -- he was just typing until things worked. (Or in some cases, he was consumed by his own cleverness.)

    Source is an indication of one's own thought process. Unfortunately, when you're looking at the source of massive real world projects that spans years in creation, hacking, and rehacking, you're seeing the though processes of uncounted current and former programmers all jumbled together. It resembles the billions of dendrite strands in a living human brain. Pure spaghetti to the eye yet a functional masterpiece. Comments are just clutter. They are only useful to the programmer during the time he's initially developping a given module. After that no one updates comments because there's no time to. Fix the code first. Fix what the compiler ignores later. Of course, there will be no later, because when the code works, the boss sees you as "now free" to start implementing the next task. The programmers knew what they were doing. They just didn't have time to spoon feed that knowledge to you. If you want to know... there's the code. And, unimaginable as it may be, yes, sometimes you don't know why shuffling some piece of code around fixed things... but it did. And sometimes that's good enough. The customer has already been screaming for a week. He needs something to work now. Think before you flame. The alternative would cost the customer account all together. Bottom line, remember? Onward.

    His second mistake was the car/house analogy. He's absolutely correct that we don't/shouldn't care what he does to his Rumpus Room or '66 Muscle Car. Unfortunately, the software we're talking about is not a private Rumpus Room. It's a bridge ... on a heavily used interstate. If a bolt starts to work loose, the DOT wants to find it, pull out a standard crescent wrench and tighten it up. They do not want to spend two weeks admiring the "artistry" of how the original bridgemaker met the schedule by using a one-of-a-kind unlocatable tool to attach two pieces.

    Well, this seems to agree despite it accusing me of a "mistake". This is right. "Get it done". Fix the bug and move on. Did you scrawl a note on the steel girder next to the bolt explaining why it was replaced and update the blueprints to reflect that this bolt may be of a different thread width, alloy makeup, age, etc.? Hell no. the next guy will not analyze why your bolt is failing 50 years later. He'll just tigten it or grab another bolt out of his truck from another bridge and ram it in there. He will not design, cast, and forge a new bolt from slag. Moving on...

    He is correct that, once you leave Uni, you will find that practice wins out over theory. Alot of Software Engineering theories are (at worst) claptrap, or (at best) a germ of a good idea wrapped in layers of claptrap.

    The problem with the theories is that they assume the problem is fully or even partially defined beforehand. They neglect design changes, feature requests, outright reversals of the desired goal mid-project. The user will change what he wants once he sees the work in progress. Software engineering theories that cannot tolerate continual changes and bashing are claptrap. What's more important is that SWE theories all assume you're starting from scratch. WTF?! No SWE theories even exist that have a pre-existing, hacked many times over, messy pile of code as their starting point. So much for the textbook solutions. Hacking new stuff into a crusty hulk is a skill, sadly, that schools don't teach. And which do the graduates end up dealing with more often? Clean slates or dozen/hundred/thousand man-year horrors that gotta keep chuging along?

    This, however, does not excuse you from writing clean code. Document tricky solutions. If you don't document tricky solutions, people will correctly assume you didn't really understand what you were doing.

    "If it was hard to write, it should be hard to understand.", words from Mel, one of my few successful graduates. A good kid. Did well for himself. Time. Time. Time. There's just not enough of it to splurge on comments. And comments that are out of date with the code are WORSE and far more DANGEROUS than no comments at all. Do you KNOW that you'll have time for adding/adjusting comments after the new feature or bug fix ships? Heck no. And you certainly can't do it beforehand, because you haven't written the code yet, or may get pulled off onto a more important project. Your comments will confuse. Even if you do have spare time, don't do it! The next programmer will modify your function and not update your comments. Now, if bugs appear, they'll be your fault and your screw up! And the bug fixer (a third person now) will be addled by your now eroneous comments. Comments are just too risky. The code is always true and never lies. Tell a man how you built a frob and he'll understand frobs. Now give him a modified frob, and he'll break it because his instructions are wrong. Teach a man how to reverse engineer, and he'll be able to figure out how anything works without relying on out of date schematics (comments) confusing him.

    Also, arrogance will come back to bite you. I once saw a programmer publicly (and sweetly) toasted because the comment
    /* Don't change this, because you're too stupid to understand it */
    The toasting came from another engineer because the code which followed that comment was not only convoluted, but it contained an error.

    The other engineer has no sense of humor. Besides, I'm not sure who's really being arrogant here. The other engineer is wasting his time being smug and court-marshalling people and boosting his own ego instead of fixing the damn bug and getting on with work. Besides, there's nothing wrong with arrogance so long as you're getting the job done. I ignore comments from most of management. Let the functional code be my judge. Bugs happen. No need to get all bent out of shape over it. Just fix it and move on. What's the employee's total track record look like? That's what matters to me. And that's what matters to the boss.

    Thank you class. Your homework assignment for next week is to realize three things:
    1.There is a balance between deadlines and good code.
    2.There is a balance between "artistic freedom" and uniform standards.
    3.How well you strike these two balances determines your overall worth as a programmer (in both a spiritual and a monetary sense).

    Forget that:
    (1) You have the best looking code but the poorest reputation for meeting deliveries, so no one will want to deal with you.
    (2) Art is irrelevant. Standards schmandards. Code that works is beautiful.
    (3) How your boss and the business world determines your worth as a programmer is of greater importance. Working code, on time gets more smiles and raises and promotions than "good" programmers still fscking with last month's task while the customer has long since jumped ship to your competitor. Spiritual worth is a seperate and unrelated issue. And I'll say it again because it bears repeating: Quick thinking master hackers who can do the magic again and again despite laying waste to the original vision and still keep on kluging and have it keep on working are what companies want. If you can do this, you will succeed.

    Have a good holiday. Class dismissed.

    Indeed. And to you all.

    1. Re:Prof. Bruce here again. The TA has been fired. by Anonymous Coward · · Score: 0

      You rock! You are 100% correct. I have been
      in industry for several years and you are the
      real deal. You should write a book.

      Please moderate up!

  132. Re:TA says: Poor Prof. Bruce, here' your meds... by Anonymous Coward · · Score: 0
    Sigh. Oh, poor Prof. Bruce. You're so wrapped up in bad karma.

    The trouble is, when you build a bridge with your crappy "get-it-done-at-all-costs" mentality. The problem is that the bridge collapses while the DOT is trying to figure out how to tighten the damn bolt. Since you were so clever in your construction that even that simple operation is a complicated mess.

    Of course, after the bridge collapses, you point your finger at the folks who where driving over it, or at the poor DOT engineers who were trying to untangle your mess.

    Read my homework assignment. You might benefit from it. Certainly, you can't spend all the project time waving your hands and philosophizing about how to do the task. But setting your thick ass down in a chair typing until something works is almost as bad. The keyword here is balance. If you can't write code that is easily maintained, then you can't write code . But I suspect you're tenured now and will never learn. You'll continue using the constant 100 in your code instead of taking 3 seconds to #define FOOBAR_ARRAY_SIZE 100

    Don't worry though. One of us truly talented "Junior Programmers" will always be there to clean up the mess you left behind.

    It's a thankless job. But if we didn't do it, there'd be no bridges.

  133. Re:More meds for Prof. Bruce by Anonymous Coward · · Score: 0
    A couple additional points:

    The "arrogant" coder was seen as a "golden boy", by management, but a fairly incompetant jerk by anyone who could code. He basically pulled his "get it done" act to impress managers and get ahead. That's why his comeuppance was so sweet. As far as I know, he still thinks he's God's gift to computers.

    As for the deadlines, I've spent the past 15 years working with deadlines. You can blame clueless bosses if it makes you feel better. But I've found that you usually can point out why something needs to be delayed or reduced in scope. Be honest and firm. It works for me, but YMMV.

    As for the code which resembles dendrites ... I've seen that stuff. Have you ever taken two seconds to wonder how it got like that? No, I don't suppose you have. I'm not idealogical enough to think that code will always be pure and chaste, but well-designed code will stand up to enhancements and expansions better. Sure some changes can turn the code sloppy over time. But there is no reason for addition of related features and bug fixes to turn a program into a map of the "Brain that Wouldn't Die".

    Reread my bridge example. You've missed the point -- which was the DOT guys can't fix the loose bolt before the bridge collapses because the joint looks like nothing else. Sure in a pinch they can break out an I-beam and a couple of props. But if you had properly designed the joint, then their fix is much quicker and much safer.

    Anonymous Kev

    PS: I didn't realize I was flaming you. My goal was to use your format to present my opposing view. Now what were you saying about needing a sense of humor?

  134. Three true stories by ebh · · Score: 1
    Long time listener, first time caller...

    I swear I am not making any of this up.

    1. A programmer I knew on a COBOL project in 1982 deliberately obfuscated his own code by making all his variables four letters of a keyboard diamond, e.g., ESXD. He developed a system where he could derive a variable's purpose based on which of the seven possible diamonds it belonged to, which corner of the diamond it started on, and whether it went around the diamond clockwise or counterclockwise.
    2. I worked on an embedded system which had been written in a weird macro-assembly-like language. When it came time to build the new version, going from an 8080 to a 68000 and from that assembly to C, our PHB was the only one who claimed he could meet the deadline, this by translating the code line-for-line. After all, the code works now, so a straight port will work without any of the engineers having to know how it really works (or how to program in C), right?
    3. Of course that same project went *WAY* behind schedule. A year and a half into it, the higher-ups decided to audit the project to see what was going wrong. Obviously, a big part of it was that the engineers didn't know how this decade-old patched-beyond-recognition code did its thing. Like good programmers, when we hit code we couldn't figure out, we commented it as such, e.g., "I don't know why this is here, but it breaks if we take it out," as a reminder to go back and decipher it someday. But then, to cover his backside in the audit, the PHB instructed a secretary to remove with prejudice all comments in the code that might indicate something we were unsure of. So she did. Good thing he didn't teach her how to hack SCCS files.

    That PHB got promoted three more times before he retired.

  135. Re:Hungarian notation by scrytch · · Score: 2

    > What is maxTypeCode? A string? An int pointer? Pointer to a user defined type?

    Unless you're writing a device driver, WHO CARES? If you stick to the functional interface used for creating, setting, and passing that value, the type of maxTypeCode is OPAQUE. It's called ABSTRACTION, something we learn when we stop having to know encode our routines for sizeof().



    --
    I've finally had it: until slashdot gets article moderation, I am not coming back.
  136. The problem with becoming invaluable... by scrytch · · Score: 3

    Is that you get chained to your code. The volume of documentation on my code is bigger than my code, because I can hand it to someone, say "this is all you need to know", and leave that code behind. Forever. On to bigger and better projects.

    --
    I've finally had it: until slashdot gets article moderation, I am not coming back.
  137. Widget! Gizmo! by goliard · · Score: 1

    Not to mention "widget" and "gizmo". These along with "thingy" were my favorite object/function/variable names in college.

    If a problemset was hard to do, it should be hard to grade! ;)


    ----------------------------------------------
    --
    -*- Any technology indistinguishable from magic is insufficiently advanced -*-
  138. Re:Hungarian notation by dgoodman · · Score: 1
    Hungarian notation is far more annoying (to me) than keeping than spliting the pane (in vc++) so i can see the decl's at the same time (or just scrolling in vi for that matter). Whats worse, is to look this up, i have to deal with MSDN: also spelt EVIL (ever forgot what callback the little X button in the upper righ hand corner of a window calls? try finding that...)

    quick quiz: from memory, tell me what these HN prefixes mean (answers here. no peaking, and no searching msdn)

    1. i (ok, thats really easy...)
    2. p (hrm, not to hard either...)
    3. ch
    4. f
    5. mps (could be easy, could be hard, depending)

    anyway, im sure i could dredge up more examples. one can verify my answers by whipping out msdn, searching for "Hungarian Notation", and reading the handful of docs that come up.

  139. Items that Ada prevents by T.E.D. · · Score: 1
    Generally languages encourage good and bad programming practices; they can't out and out prevent bad code.

    But its interesting to note how many items on the list can't be done in Ada. By my accounting 11 items of the 55 (20%!) aren't an issue in Ada:

    • 12 (no optional block delimiters)
    • 14 (case insensitive)
    • 16 (literals are not type-designated in this way)
    • 17 (case insensitive)
    • 23 (passing mode is explicitly stated in interface)
    • 27 (arrays are not pointers, and pointer arithmetic is not allowed)
    • 37 (names must be unique within the same scope)
    • 44 (named notation insulates clients from parameter order)
    • 48 (no macro preprocessor)
    • 52 (no macro preprocessor)
    • 53 (only one way to declare arrays)
    • 54 (its tough to do this conversion in any way other than the straightforward one)
    I guess one good addition would be:
    • 56. Refuse to use Ada. If your manager presses you, insist that no-one else uses it, and point out that it doesn't work with your large suite of tools that work around C's failings like lint and plummer.
  140. Wake up, it's a joke. But seriously... by somebody · · Score: 1
    Why are people arguing as if this is seriously encouraging programmers to behave like this? None of the items are things programmers gain any efficiency from.

    Seriously, how many programmers have had to deal with some lame-ass coding standards designed by a committee that obviously hadn't done any real coding in years? My personal favorite is to avoid the use of any and all loop jumps, like break or continue. How is it easier to read 8 levels of nesting, with all sorts of redundant comparisons and operations, when the whole thing could be fixed with a simple return? This is the type of thing that kills big projects. Ever had a code review, where nobody has time to look at the actual content and purpose of the code, so they just start rigorously enforcing these arbitrary coding conventions? Inevitably, the code gets completely rewritten for a bug fix (with no code review) and the standards go out the window.

    A lot of people have commented about changing requirements causing redesigns. My complaint is that too many people (managers) refuse to see beyond the current requirements. Sometimes, you just know that the customer is going to want something eventually, so you want to spend a little extra time up-front preparing for it. But unfortunately you get forced in to doing things the quickest way, and then it's too expensive to add the features that would really be useful.

    It sucks, but usually you need to be first to win the market. But if you look at most products that were first to market, they sell well for a while, but eventually the competitors overtake them. It's usually because they didn't plan ahead in the original implementation, and are now left with unmaintainable code that needs to be completely rewritten. There are too many examples to cite..

  141. mistakes in 2 points: by Anonymous Coward · · Score: 0

    I sent the author this email to get the mistakes fixed: Subject: Suggested amendments to "How To Write Unmaintainable Code" Roedy, I loved your "How To Write Unmaintainable Code"! It was all dead-on, great advice, especially for those new to programming! All of it, that is, except for the latter parts of points #10 and #25. The latter halves of points #10 and #25 are marred by gratuitous USA-bashing which is not only factually inaccurate, but lower the tone of the points made. I'll address the inaccuracies: Point #10: (...) Consider variant spellings as a variant on the ploy, e.g. mixing International colour, with American color and dude-speak kulerz. (...) Comment: What International Standard are you talking about? The only thing noteworthy about "colour" is that it's the spelling used in Great Britain and all its colonies. It's no more of a spelling standard than Queen Elizabeth's face appearing on all bills is a currency standard. Furthermore, there are other words with variant spellings/forms that are commonly used within the same country. Example: Muslim/Moslem, lit/lighted, etc. Perhaps you should change that part of #10 to say that a programmer should stick to the same spelling/form that already appears in the code, for consistency's sake. Another thing to add would be that variant spellings of options should be accepted as input by a program. Example: a program that accepts "-color" as a command-line option should also accept "-colour". Variant spellings/forms will always be with us, and we just have to accept it, unless, of course, our aim is to simply piss-off other groups of people. Furthermore, if "color" vs. "colour" strikes you as too hard to handle, what do you think about Java making it possible for Indian programmers to name their variables, classes, and methods in Hindi? Your implicit assumption in #10 is that all code is going to be written in English. Perhaps you should make this explicit. Point #25: In engineering work there are two ways to code. One is to convert all inputs to S.I. (metric) units of measure, then do your calculations then convert back to various civil units of measure for output. The other is to maintain the various mixed measure systems throughout. Always choose the second. It's the American way! Comment: This point is just flat-out wrong and ought to be deleted from the article. The S.I. units, athough they comprise an excellent system, are certainly not the only system of units used. (Many physics calculations, for example, are much more cleanly expressed using energy units of electron-volts, or eV, rather than Joules.) If, for whatever reason, other units are used, it makes no sense at all to convert them to S.I. for the purpose of making an intermediate calculation. This pointless conversion simply obscures what's going on, causes precision loss, and makes the program run slower. God forbid it should take place inside a loop! The important thing is to document the units used for each variable, as you pointed out in point #24. I sincerely hope you will address these inaccuracies so that not a single flaw remains in your otherwise excellent on-line article.

  142. Asking for the boot of Karmae by Anonymous Coward · · Score: 0

    Nasty article. So much chumpness and gravity that I gained twenty pounds of angst just reading it. In the end, the karmic boot will jam itelf up your ass is you follow the path of confusion. The simplest path is always the best and is usually the easiest. True programming geniuses don't rely on ninja smokebombs, fake teach or plastic vomit to keep their jobs. Get thee to a nunnery! J Carter Bermuda

  143. Re:Hungarian notation by Raul+Acevedo · · Score: 2
    I understand what you're saying. However, those examples are not contrived. Those are pretty close to real variables from real code I had to work with. Actually, they were part of the 2100+ line function that I referred to in my first point. By the way, I replaced the 2100 line function, with its obfuscated naming conventions, which wasn't completed and didn't work at all, with 12 functions over 718 lines of code---over 20% comments---that the project manager, a non-coder, looked at and said "Hey! I can understand this! And it should work!" And it did. :)

    In any case, your point is well taken, that Hungarian notation is not as obfuscated as my not-so-contrived example makes out. My only experience with it however was on this one project which did have such convoluted examples. Hopefully my example speaks to the broader issue of useful variable naming, not just Hungarian notation.
    ----------

    --
    In a real emergency, we would have all fled in terror, and you would not have been notified.
  144. Fun is always fun, no matter what the language. by kcarnold · · Score: 1

    I cannot possibly be expected to read all of these comments.

    The makings of some of the worst programming problems in the world in one little web page. I propose that you try these suggestions with Scheme (never heard of it? Try appending a .org):

    1. In Scheme, variables have no type. That can really get fun. You can pass functions as arguments to other functions just as easily as any other data. You don't even have to define it somewhere else and pass a pointer; just put it there.
    2. You can put stuff wherever you want. For example, you can put all of your methods in one big list, and instead of using the function's name, use a reference into the list. As an added bonus, redefine the list somewhere in the middle of the code, deep inside some function. Your functions can be designed to automatically delete themselves when called! (You can do this even if your functions aren't in lists.)
    3. Sort of like #2, you can redefine identifiers such as functions once they are declared. A function could do one thing at one point in your program at one time, and another thing at another time.
    4. Scheme allows your functions to recurse as often as they please. No stack space concerns! That means two things: One, you can have hideously complex algorithms, and two, you can split every operation into tiny little pieces, and scatter these functions all over your code. Have them change their purpose often.
    5. Stuff that gets executed can look a lot like stuff that isn't supposed to get executed. The way for calling a function is (name arg1 arg2 ...). The way for making a data list is '(thing1 thing2 thing3 ...) Oops! That isn't a function call, that's just data! Confuses the heck out of people who are not you.
    6. Your code maintainer likely doesn't know Scheme. If your boss asks why you are using this language he's never heard of before (it's a dialect of LISP), you can tell him that Scheme is a functional, properly tail-recusive dynamically-typed data processing language and it is great for parsing complex things and that it is very flexible, and it allows you to write elegant and simple code, all of which are true. Of course, you don't have to write elegant and simple code, do you?
    7. Quasiquoting is a very good way to make things a lot more complicated. Basically it allows you to execute stuff while constructing a list, and put the results into the list. There is a very useful variation, however, and it's called unquote-splicing (whatever that means). If the function that you want to put in returns a list, it strips the parenthesis off of the ends and inserts each element as an element in the list. So your lists can vary widely in length from one time to another, depending on what your functions return.
    8. There are many different implementations of Scheme, and they are substantially different in I/O. So the code that compiled just fine on your computer using one implementation will fail miserably when your code maintainer comes in and tries to execute it on his implementation.
    9. Fun Thing To Do With Scheme Number 10: Make your functions do something different depending on how many arguments they are passed and how many times they have been called. The possibilities are almost endless: a little, innocent-looking loop in your program calls the function about 10 times, and each time it is called, it does a different thing. To discourage the one who plays around with your functions, have it delete your master data list and then undefine itself if someone calls it more than the number of times you know that it should be called. Of course, you could have a secret parameter embedded deep within your arguments that allows you to call it however many times you want.

    I think I had better stop it at 10; the fun could go on, but it doesn't. Just another little morsel: Scheme comments are semicolons. Play tricks on people who are used to shell scripts. And there are some important cases where #'s are legal, specifically to quote an atomic (bunch of characters put together that isn't a string) element that includes spaces. Tada! Your comments look like code, and your code looks like comments!

    I use Scheme how it was intended to be used: elegantly and flexibly. But there is a lot of room for error--Exploit it!

    Kenneth Arnold

    PS - Scheme really is a neat language, if you have enough time to learn it. It's a lot like Perl in that it's great for parsing stuff, but it's more flexible, for example, the function rules are greatly relaxed (see #1.)

  145. Re:Hungarian notation by Anonymous Coward · · Score: 0

    True, Hungarian notation isn't useful in the cases where you "don't care" about the type. That's because those cases are far fewer than you seem to indicate in your post.

    HN is about preventing problems that occur when you interface variables of similar-but-different types. It helps you keep track of which are of which kind, when the compiler can't tell the difference.

    For instance, you might use a notation to indicate that your variable is a 0-based index or a 1-based index. (Another more common example is the "Last" versus "Limit" distinction) This is not something the compiler can know (yet) unless you decide to use completely incompatible types, which typically introduces more problems than it solves. It definitely creates a potential for problems when someday you try to use a 0-based with a 1-based and your compiler doesn't complain.

    So yes, you can easily set and create any value without knowing its type. But you're wrong about "pass" because you can't use it as a parameter without knowing *some* type information. Sometimes the *some* is within the means of the compiler, sometimes not.

    Presto

  146. Some good points... by Evil+Poot+Cat · · Score: 1

    One of the better points I've seen in the posts is something to the tune of "It doesn't matter how well you write your code if the person that comes behind you just doesn't get it", which results in the writer getting stuck with the code.

    The reverse is true, in that poorly written code can be understood by someone else, and that someone gets stuck with the code (and job security) instead of the writer. And right now, that someone else is me. :)

    Note to sucky coders: A major part of your retirement planning should include recruiting bag-holders to maintain the code when you leave. :)

  147. The dreaded Underscore by Anonymous Coward · · Score: 0

    I loved doin this back in high school to mess with my cs teacher... 15 variables of different lenghts of underscores. Worked in pascal... works in C++ :) int _ = 0; int ___=0; int __ = _++; _ = __ + _ - ___ etc... if the font is weird, all those underscores connect :)

  148. Re:I didn't read the whole list (i don't like horr by Abigail-II · · Score: 1
    why not write the code in perl such that when the program starts it reads the code in and then executes from refrence to subs?

    You mean you did what the Autoloader and Selfloader do as well?

    -- Abigail

  149. Re:Hungarian notation by Arandir · · Score: 2

    It makes all the difference in the world if you're a code *maintainer*, as this whole article is about. If you write code only for yourself, then you can use any coding standard you want. But then again, if you're only coding for yourself, why even release it :-)

    A maintainer DOES NOT want to flip up to the top of the header files each and every time he runs across a variable to find out what it is. If a bug is signed versus unsigned related, "maxTypeCode" doesn't help at all. But an "uMaxTypeCode = -3" sticks out like a sore thumb.

    --
    A Government Is a Body of People, Usually Notably Ungoverned
  150. Re:Hungarian notation by Arandir · · Score: 2

    Answers are: integer, pointer (to something), char, float, and who cares :-)

    Without looking anything up, I think mps is a Microsoft/Windows/vc++ specific prefix. I do recall that "h" was for handle, and when you're using handles for *everything* in windows programming, it makes it much easier to distinguish between ints, files and handles.

    But just like the guy who avoided all whitespace because he was following the rule to keep all functions one page in length, you can overdo HN. The basic idea is to use easy to remember mnemonics with prefix notation. Using "intEmployee" and "dblSalary" is equally useful.

    --
    A Government Is a Body of People, Usually Notably Ungoverned
  151. ...or profanity... by Anonymous Coward · · Score: 0
  152. one last comment by hawk · · Score: 2

    >Oh well, lets leave this one to the archives of
    .

    Good idea, it's beaten to death. But one little note: I'm not talking about US employment law, but the Common Law of England :) For the most part, that is still the law in the U.S., but were old law by the time we separated.

    hawk, esq.

  153. Re:Hungarian notation by Doctor+Memory · · Score: 1


    IMAO, HN was invented by someone who was too lazy to write a simple cross-referencer. Any bugs dealing with incompatible varible types should have been worked out long before a maintenance programmer gets hold of the code. While some may complain about having to scroll up to the top of the routine to check a variable's type, what am I supposed to do with someone who uses their own personal "Hungarian" notation? Like (my favorite) the person who bases their notation on their redefinition of the standard C types:
    #define UINT unsigned short /* Actual example */
    UINT uiCounter;


    And what the hell's up with "lpsz" anyway? Long Pointer[1] to String, Zero-terminated -- what other kinds do you work with? Sure there are fixed-length strings, but do you then feel compelled to prefix them "lpsf30" to indicate a Long Pointer to String Fixed at 30 characters? Why not just prefix with "s" for String and special-case the exceptions? Not that I care; I tend to use string descriptors & my own string library to prevent buffer overruns & other associated problems -- but I imagine lots of people do that.


    [1] And don't get me started on Long Pointers! If you're using a proper (non-segmented) CPU, you don't have to waste time considering pointer size and memory models...

    --
    Just junk food for thought...
  154. Re:Hungarian notation by Arandir · · Score: 1

    "HN was invented by someone who was too lazy to write a simple cross-referencer."

    Do you know who you're talking about?

    "If you're using a proper (non-segmented) CPU, you don't have to waste time considering pointer size and memory models..."

    It must be nice to pick and choose the assignments your employer gives to you.

    --
    A Government Is a Body of People, Usually Notably Ungoverned
  155. Re:I didn't read the whole list (i don't like horr by toast0 · · Score: 1

    yeah probably

    i didn't know anybody was as twisted as me.....

    you can save a lot of work by being twisted though... rather than a bunch of if thens when you get something from a server to call a function named one of the parameters, just call &{$func{$param}} (after checking if it exists....)


  156. You're pathetic by Anonymous Coward · · Score: 0

    Your drivel about how victimized you are makes me gag. If you agree to do something, do it. If you don't think you're being paid enough to do a new task that wasn't in your contract, renegotiate your contract.

    Having a tech support rep do some VBA coding in Excel doesn't sound to me like they're asking for much. I happily did some VBA for Excel back when I was a TS rep, just for the additional challenge, and it ultimately led me to big bucks as a full-time C++ & Perl programmer for a different company. Still, you were free to choose, so you could have renegotiated or just refused. And none of that "no, I wasn't free, they would have fired me" nonsense. You could just as easily have fired them (gone to work for someone else) for refusing *your* demands. If they weren't willing to renegotiate, then maybe the value of this VBA work you did wasn't as great in their minds as it apparently was in yours.

    Do what you say you'll do, or don't say you'll do it. Negotiate up front, and deliver slightly more than you promise, and the world can be yours, especially if you have valuable computer skills. If the other party asks you to do more than the contract specified, decide whether to give it, or charge for it, or otherwise renegotiate as you feel appropriate, but do so up front. If they don't deliver on their end, don't do business with them, and learn how to structure a contract so as to minimize such risks in the future.

    Or, walk around whining about how victimized you are by Business and Corporations, engaging in pathetic little acts of sabotage to secretly compensate in your own mind for what you are too wimpy to publicly negotiate, and you'll be a lackey forever -- and rightfully so.

  157. Re:Hungarian notation by sumner · · Score: 1
    A maintainer DOES NOT want to flip up to the top of the header files each and every time he runs across a variable to find out what it is.

    The language has type information, don't be redundant by encoding it into the variable names. Any decent editor will tell you the types of the variables without having to "flip up to the top of the header files" and without mangling variable names.

    Sumner

    --
    -- rage, rage against the dying of the light