• Rune Fevang (unregistered) in reply to Enric Naval
    Enric Naval:
    user="Alex Papadimoulis"
       
    

    If nType = 1 Then 'Root Level, retreive parameters ... Else Call ProcessRule(nType - 1, nRuleIndex, sLogic) Exit Sub End If

    I assume that nType did something when the routine was written for the first time, or at least was intended to be a very clever way to do something.

    Later on, the programmer must have noticed that recursity is useless for almost anything :) and then he wrote the enormous Select Case section that only took into account nRuleIndex and sLogic.

    Then, because all the code in the system must have been littered with calls to the procedure that used nType, he couldn't take out the nType parameter without breaking half the applications in the bussines, so he simply deleted the cases for nType==2, nType==3, etc.

    One of the WTFs is not rewriting the recursive code to some simple assignment like nType=1, and then proceeding as usual. Maybe he thought that changing from recursive to procedural could break legacy code? :) Do electric sheeps mind that they dream using recursive or using procedural functions, as long as they dream the same dreams?

     

    Well, he couldn't do that, he would have to add things like if(nType < 1 || nType > MAX_STACK_SIZE) throw new StackOverflowException();

     

  • (cs) in reply to Rune Fevang
    Anonymous:
    Enric Naval:
    user="Alex Papadimoulis"
       
    

    If nType = 1 Then 'Root Level, retreive parameters ... Else Call ProcessRule(nType - 1, nRuleIndex, sLogic) Exit Sub End If

    I assume that nType did something when the routine was written for the first time, or at least was intended to be a very clever way to do something.

    Later on, the programmer must have noticed that recursity is useless for almost anything :) and then he wrote the enormous Select Case section that only took into account nRuleIndex and sLogic.

    Then, because all the code in the system must have been littered with calls to the procedure that used nType, he couldn't take out the nType parameter without breaking half the applications in the bussines, so he simply deleted the cases for nType==2, nType==3, etc.

    One of the WTFs is not rewriting the recursive code to some simple assignment like nType=1, and then proceeding as usual. Maybe he thought that changing from recursive to procedural could break legacy code? :) Do electric sheeps mind that they dream using recursive or using procedural functions, as long as they dream the same dreams?

     

    Well, he couldn't do that, he would have to add things like if(nType < 1 || nType > MAX_STACK_SIZE) throw new StackOverflowException();

     

    Well, Moore's law says that the stack doubles in size every 18 months... or something similar. Just believe, I'm a professional :)

    So, eventually, the stack will be so big that the positions available in the stack will be more than the maximum number that fits in a Long variable :) I'm guessing one or two hundred years, or something.....

  • BLQ (unregistered) in reply to masklinn

    masklinn:
    I think you failed to noticed the part where he mentioned the word maintain.

    Surely you mean "maintenanced" (right Alex?); like "architected", all nouns should be "mistaked" as verbs until the sentence is totally "bad-grammared" and sounds completely "idioted".

  • (cs) in reply to Hugo
    Hugo:

    Some time ago (no, actually a long time ago - I'm talking PL/1 on a mainframe computer, that long ago!!), I was given a similar task. When I was done, I delivered three deliverables:

    1. Rewritten code that did exactly what the old code did (only with much less lines of code, much more comments, better structured and performing about twice as fast);

    2. A complete set of documentation describing what the program actually did (including all the things I suspected to be bugs);

    3. A seperate list of only the functionality that I suspected to be bugs, to be reviewed by end users and specialists, so that they could decide if exploding when x, y, and z happens was indeed intended behaviour or should be removed.


    I hereby nominate you for Code Maintainance Hero of the Month.

  • (cs)

    I'm glad this site exists.  Every time I write something I know is just awful (in this case must be done by the end of the week or I can't take my vacation), something poops up here that is so many orders of magnitude worse that I can feel good about it anyway.


    Now excuse me, I need to write enough comments and do enough refactoring that my successor (that is me after a week in the back country) thinks "I wish the authoer had been given enough time write this in a nice way", instead of "WTF, hey Alex how do you like brillant code?"


  • (cs)

    Only greedy selfish coders surround themselves with dozens of functions.

    Good code fits neatly in 1 super function!

    Up up and away, super function to save the day....

  • Oli (unregistered) in reply to travisowens

    So let's see the pseudo-XML system?

  • (cs) in reply to hank miller

    hank miller:
    Every time I write something I know is just awful ... something poops up here that is so many orders of magnitude worse that I can feel good about it anyway.

    Best Freudian slip ever?

  • (cs) in reply to BLQ
    Anonymous:

    Surely you mean "maintenanced" (right Alex?); like "architected", all nouns should be "mistaked" as verbs until the sentence is totally "bad-grammared" and sounds completely "idioted".


    So, I guess it is true that any noun can be verbed.


  • (cs) in reply to Mike
    Mike:

    Oh I completely understand how frustrating it can be to look at crap code. I’m thinking more in a business sense. Its not easy to justify the expense of a rewrite unless specific defects are addressed or additional functionality is introduced. (i.e. have something to show for it). If you can point to the code and say, “Yeah, all this is going to explode if x, y, and z happen”, then yes, it is justified. But if you just don’t like the (lack of) design, or the (lack of) coding standards, or anything which has no bearing on the actual use of the product, then you’re just wasting money.

    Let me introduce you to the concept of Technical Debt.

Leave a comment on “XML, Recursion, and ... VBScript?”

Log In or post as a guest

Replying to comment #:

« Return to Article