How to eat a behemoth



  • I was told a week ago to look into a (very) old print routine that was behaving weirdly with some newer modifications. Eventually tracking the "action" end of the routine to its origin I discovered a behemoth of 1700 lines of code... to print a bill. It took as an argument the number of the bill in the database, which I felt was fine, it's certainly how it's been done in the rest of the program, so that's all right. However, it didn't just print the thing, it also changed the status in the database to "printed", and vast quantities of updates in different areas of the program... my head started spinning. I did manage to narrow down the problem to one update the behemoth did that it shouldn't do in the case of the new method, but that update I was actually incapable of finding through the layers upon layers of obfuscation.

    Finally I had had enough. I told the boss that no, sorry, I'll have to rewrite this thing if I'm going to do it, as it needs to be broken down into individual tasks, and that might take a while. She had the bright idea of giving THAT job to the guy who originally wrote the method, to save time. So she called him in and did the old "how do you eat an elephant" bit...

    Well, my co-worker was apparently working on something atrociously boring, so he welcomed the change... and two days later, he had split his behemoth into manageable chunks that did one specific thing, and presented me with a list of his new methods and what they did. Happily I started coding the bit that had originally given the rest some trouble... and it broke. Upon investigating, the reason soon became clear: having broken up his method into smaller, single-task methods, he had dutifully made sure that each of them called the next one at the end of itself. It seems that HIS idea about how to eat an elephant was to grind it into a huge sausage-chain, and force-feeding the entire thing to you in one go...



  • @WitherVoice said:

    It seems that HIS idea about how to eat an elephant was to grind it into a huge sausage-chain, and force-feeding the entire thing to you in one go...
    First of all I'd like to thank for you for showing me the term sausage-chain programming. Second I know people who do this kind of thing all too well. One function calls another at the end of its run instead of passing control back to its caller to call that particular function. You end up with functions whose names are meaningless since calling one ends up calling so many other completely different ones. What I don't understand is how sausage-chainers get the idea that this is a good thing to do.



  • @Welbog said:

    First of all I'd like to thank for you for showing me the term sausage-chain programming.

    "Sausage-chain" means something completely different in the group I associate with. 



  • @morbiuswilters said:

    "Sausage-chain" means something completely different in the group I associate with.
    Good to know!



  • @morbiuswilters said:

    @Welbog said:

    First of all I'd like to thank for you for showing me the term sausage-chain programming.

    "Sausage-chain" means something completely different in the group I associate with. 

     

     Google Image search results:

    Sausage Chain



  •  Well...

    function one(){

    writeln("They said split");

     two();

    }

    function two(){

    writeln("It up, but they said nothing about making it");

    three();

    }

    function three(){

    writeln("the least bit useful, so he just went on to do exactly what he was told... sausage-chain");

    }


Log in to reply