Sometimes null - continued



  • This is really part of Sometimes null from yesterday, but it's such a wtf that I thought it deserved it's own entry.

    This is the 3800+ line function (there were 4 similarly grotesque functions in one file), with code details omitted, so you can clearly see the structure of what the guy wrote. The only comment in the entire file was in an empty else block, indicating that the else block was empty. OBTW, there were 37 exceptions thrown, but not checked exceptions, oh no; Runtime exceptions! (Forgive me, but I think I may have deleted an extra brace or two while deleting the code details).

      public ReturnType<x> doStuff(TripleNestedGenericType<x> stuff) /* OP: note: no throws-clause here */ {
    for () {
    if () {
    for () {
    if () {
    if () {
    }
    if () {
    if () {
    } else if () {
    for () {
    if () {
    for () {
    if () {
    for () {
    if () {
    if () {
    } else if () {
    } else {
    }
    }
    }
    if () {
    }
    for () {
    for () {
    if () {
    }
    if () {
    if () {
    }
    }
    }
    }
    if () {
    if () {
    if () {
    }
    }
    if () {
    } else {
    }
    if () {
    } else if () {
    } else if () {
    } else {
    }
    }
    }
    }
    }
    }
    }
    if () {
    } else {
    }
    }
    for () {
    if () {
    if () {
    }
    if () {
    if () {
    } else if () {
    for () {
    for () {
    for () {
    if () {
    }
    }
    }
    if () {
    for () {
    if () {
    for () {
    if () {
    }
    }
    if () {
    }
    for () {
    for () {
    if ()
    }
    if () {
    }
    }
    }
    if () {
    if () {
    if () {
    } else {
    }
    if () {
    } else {
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    for () {
    if () {
    if () {
    for () {
    if () {
    for () {
    for () {
    if () {
    if () {
    }
    for () {
    for () {
    if () {
    }
    if () {
    if () {
    }
    }
    }
    }
    if () {
    for () {
    if () {
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    return...
    }

    </x></x>



  • Looks like someone took a picture of the Alpes, flipped it 90° and then converted it to ASCII art.



  • This would be the antithesis to the "no if" movement.



  • @Rhywden said:

    Looks like someone took a picture of the Alpes, flipped it 90° and then converted it to ASCII art.
     

    It's an implementation of the Tour de France.



  • @snoofle said:

    } else {

    Well.... at least they cuddle their braces.



  • @Xyro said:

    @snoofle said:
    } else {

    Well.... at least they cuddle their braces.
    Only some of the time - that was mostly me formatting it so that I could keep track of it. The indentation of the code can only be described as random. Expecially on the more deeply nested stuff - often, they'll move a whole block 60 columns to the left (presumably so they can see it on screen without scrolling) and leave it there.



  •  Please be running Checkstyle on this monster.

    I need to know its cyclomatic complexity, it must be approaching 3 figures...



  • @snoofle said:

       public ReturnType doStuff(TripleNestedGenericType stuff) /* OP: note: no throws-clause here */ {
    for () {
    if () {
    for () {
    if () {
    for () {
    if () {
    if () {
    if () {
    } else if () {
    for () {
    if () {
    for () {
    if () {
    for () {
    for () {
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }

    Good grief, that's O(n7)! ... Well at least it's still polynomial.



  • @derula said:

    Good grief, that's O(n7)! ... Well at least it's still polynomial.

    There's no way to tell what order that code is, and you know it. It's just bad code.



  •  @derula said:

    Good grief, that's O(n7)! ... Well at least it's still polynomial.

     There could be a call to an O(2^n) function somewhere in there.  I mean, it wouldn't be surprising, would it?



  • @ShatteredArm said:

    @derula said:
    Good grief, that's O(n7)! ... Well at least it's still polynomial.

    There could be a call to an O(2^n) function somewhere in there.  I mean, it wouldn't be surprising, would it?

    I assumed it was O(nO!).



  • re: O(n)...

    The lists are fairly short: typically 10-20 items, but nest that 7 times and even a 3Ghz cpu appears to just halt for 2 seconds while it grinds through it. And this method is called for every record in a job. Then they wonder why their jobs take so long to run. It's not the DB, network or even disk I/O; it's the f*g horrid code!

     



  • @boomzilla said:

    @ShatteredArm said:
    @derula said:
    Good grief, that's O(n7)! ... Well at least it's still polynomial.

    There could be a call to an O(2^n) function somewhere in there.  I mean, it wouldn't be surprising, would it?

    I assumed it was O(nO!).

    0! = 1, so that's not that bad. Oh, that's an O? ... why?



  • @derula said:

    @boomzilla said:
    @ShatteredArm said:
    @derula said:
    Good grief, that's O(n7)! ... Well at least it's still polynomial.

    There could be a call to an O(2^n) function somewhere in there.  I mean, it wouldn't be surprising, would it?

    I assumed it was O(nO!).

    0! = 1, so that's not that bad. Oh, that's an O? ... why?

     

    O no, I think you didn't get the joke.



  • squeaky voice: "Oh no!"



    /explodes



  • Was one of those exceptions the little-known BranchPredictionUnitExplodedException?

    I think on this day of every year, I will light a candle and mourn for you.  I thought I was in the Ninth Circle when I inherited a 14 page-long VBA subroutine (with quintuple-nested recordset loops), but this... it's the very essence of madness.

    The original developer wouldn't happen to be Satan, would it?



  • @pbean said:

    @derula said:
    @boomzilla said:
    @ShatteredArm said:
    @derula said:
    Good grief, that's O(n7)! ... Well at least it's still polynomial.

    There could be a call to an O(2^n) function somewhere in there.  I mean, it wouldn't be surprising, would it?

    I assumed it was O(nO!).

    0! = 1, so that's not that bad. Oh, that's an O? ... why?

    O no, I think you didn't get the joke.

    😞


Log in to reply
 

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