Code Maintenance from Hell



  • So was I tasked with cleaning up a code base and I found this beautiful piece of code today. This is C# code. stop_time is defined as what, sir?

    if (the_list[0].Unit1 != null)
    {
    start_time = the_list[0].Times[0][0].AddSeconds(chart_info.Series_Offset.Start[0]);
    stop_time = the_list[0].Times[0].Length > 1 ? the_list[0].Times[the_list[0].Times.Length - 1][the_list[0].Times[the_list[0].Times.Length - 1].Length - 1].AddSeconds(chart_info.Series_Offset.Start[0] + ((chart_info.Series_Offset.End[0] - chart_info.Series_Offset.Start[0]) / (ArrayLength(the_list[0].Times) - 1)) * (ArrayLength(the_list[0].Times) - 1))
    : the_list[0].Times[the_list[0].Times.Length - 1][the_list[0].Times[the_list[0].Times.Length - 1].Length - 1].AddSeconds(chart_info.Series_Offset.Start[0] + ((chart_info.Series_Offset.End[0] - chart_info.Series_Offset.Start[0]) / (ArrayLength(the_list[0].Times))) * (ArrayLength(the_list[0].Times) - 1));
    }

    ed: fixed your newlines - btk



  • Looks like an array of objects with a member raviable that's an array of arrays or objects. Have fun, I'll conceed to that as trumping the 20k LoC JS that was generated by PHP.



  • What is the difference between "the_list[0].Times.Length" and "ArrayLength(the_list[0].Times)"?



  • ArrayLength counts the total number of elements in a 2D array. It is obviously not named well.



  • @Lingerance said:

    I'll conceed to that as trumping the 20k LoC JS that was generated by PHP.
     

     

    I remember that SP on the front page through which one could PageDown and, while briskly PageDowning, slowly realise that it's really that long.

     

     

    Edit

    There's a maxlength to tags, apparently.



  • @dhromed said:

    Edit

    There's a maxlength to tags, apparently.

    Unlike my wang.



  • @morbiuswilters said:

    @dhromed said:

    Edit

    There's a maxlength to tags, apparently.

    Unlike my wang.

    Soft, stretchy and unsastifying rubbery wangs tend to do that.



  •  Welcome,kind user!

    You have reached the website of...

    The Daily Dick Joke!

    starring your hosts:

    Dhromed aka Eric "dicky" Wood
    Morbiuswilters aka Arthropenis
    Bstorer aka The Tower of Hanoi

     



  •  Just wondering, is the list name actually "the_list"?



  • This is why I hate short hand conditionals.



  • @dhromed said:

    Bstorer aka The Tower of Hanoi
     

    First, I hate each and every single one of you for making me think of this.

    Second, mercifully presented as a link to preserve the sanity and jobs of everyone else:

    [url=http://matrix.senecac.on.ca/~lkates/wtf_hanoi.PNG]Bstorer, aka The Tower of Hanoi[/url]



  • @Lorne Kates said:

    First, I hate each and every single one of you for making me think of this.

    Second, mercifully presented as a link to preserve the sanity and jobs of everyone else:

    Bstorer, aka The Tower of Hanoi

     

    That is AWESOME.



  • @dhromed said:

    @Lingerance said:

    I'll conceed to that as trumping the 20k LoC JS that was generated by PHP.
     

    I remember that SP on the front page through which one could PageDown and, while briskly PageDowning, slowly realise that it's really that long.

    I posted a 1500 line stored procedure who'se sole job it was to generate an even larger (10k line) stored procedure 



  • @Lorne Kates said:

    @dhromed said:

    Bstorer aka The Tower of Hanoi
     

    First, I hate each and every single one of you for making me think of this.

    Second, mercifully presented as a link to preserve the sanity and jobs of everyone else:

    Bstorer, aka The Tower of Hanoi

    Who-biuswilters?  I'm sorry, but I only have one love: Lorne Kates.



  • @galgorah said:

    I posted a 1500 line stored procedure who'se sole job it was to generate an even larger (10k line) stored procedure
     

    Oh great, someone's finally managed to unify whose and who's.



  • @Zylon said:

    Oh great, someone's finally managed to unify whose and who's.
     

    Especially shaming since the correct word would be "which".


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.