• Vakieh (unregistered)

    Makes me hope somewhere, someplace, I can find one of those 'code drawings' from the obfuscation competitions materialise organically in shitty, shitty code.

  • Nesetalis (unregistered)

    Ow, my brain...

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered)

    Only a Lovecraft quote can express how this code makes me feel.

    I could not help feeling that they were evil things -- mountains of madness whose farther slopes looked out over some accursed abyss.

  • Tom (unregistered)

    Not only this developer used Goto, which is enough to deserve a slow and painful death, but he wasn't even able to use it properly... why create 88 labels (with no real name of course) when only one would be enough?

    Anyway, VB.NET is a WTF by itself...

  • (cs)

    Who is Ellis Morning? Did he win your competition about the cat that set the computer on fire?

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Tom
    Tom:
    why create 88 labels (with no real name of course) when only one would be enough?
    Because secretly, he really wanted to play the piano when he grew up.
  • (cs)

    Unless I'm reading it wrong (or it was copy/pasted incorrectly), there's an even bigger WTF

    It never gets to checking for "WSST" or later, because the 'goto label1' bypasses all that

  • (cs) in reply to Cbuttius

    Ellis is the first of several new sames you'll see around. We're still slowly going through the various submissions. It also wasn't a competition. There's no winner- everyone gets a participation ribbon.

  • Simon Peyote Joints (unregistered) in reply to Tom
    Tom:
    Not only this developer used Goto, which is enough to deserve a slow and painful death...

    Not that it exemplifies its use in this case, but goto is actually not The Devil. It does have its place (but mostly only in C).

  • curmudgeon (unregistered) in reply to Tom
    why create 88 labels (with no real name of course) when only one would be enough?

    That and the infinite indentation has me think this is generated code.

  • (cs) in reply to Simon Peyote Joints
    Simon Peyote Joints:
    [Goto] does have its place (but mostly only in C).
    It is a primitive used to build control structures. Like many primitives, it's horrible to use it directly. On the other hand, having it lets you built new control structures rather than being stuck with if and while (for, do/while and switch are in many ways syntactic sugar round those two) which, while a set that lets you express any algorithm with enough contortions, are only a fraction of what has been discovered. C doesn't have try/catch/finally (or RAII) so error handling and cleanup are necessarily rather messy. There are a few other fundamental control structures that C doesn't have and which need gotos to model well (e.g., coroutines).

    But TRWTF is when programmers create a vast mess of super-nested conditionals and boolean variables just to avoid a single goto. Yeah, goto can be harmful, but so can the things that people do to avoid it…

  • bkDJ (unregistered) in reply to pscs

    This developer has 88 problems, but a regex ain't one.

  • (cs) in reply to bkDJ

    A developer has 88 problems. Then they say, "I know, I'll use a regex." Now they have 89 problems.

  • AGray (unregistered)

    This code makes my particles hurt.

  • Rick (unregistered)

    There comes a point in every programmer's life where you find yourself wondering "Can this possibly be the best way to do this? Should it really be this difficult? Am I actually so special and unique that I'm the first person in the history of history to encounter this problem?"

    If you don't know how to wonder, you are not a programmer. Please step back from the keyboard. Now.

  • Stunned (unregistered)

    o_O Blink

  • (cs)

    The problem here is, as hinted at above, that the if/else if/else chain is badly broken, with every other else if having been replaced by a simple if. This leads the code to grossly misbehave, and I'd imagine that it returns Now() most of the time.

    (simple: it normally fails to remove the incorrect time zone symbol from the string, and therefore the Parse() call will throw an exception, dumping us in the catch, which doesn't do anything.)

    That said, I think that throwing is a good plan in this case, rather than returning an arbitrary value. And if you are going to return an arbitrary value, 25 o'clock on 7 September 1752 is far better than Now().

    For those who don't get it, here is a calendar page for September 1752:

       September 1752     
    Su Mo Tu We Th Fr Sa  
           1  2 14 15 16  
    17 18 19 20 21 22 23  
    24 25 26 27 28 29 30  
  • History Teacher (unregistered) in reply to Tom
    Tom:
    why create 88 labels (with no real name of course) when only one would be enough?
    Isn't it obvious? He wanted to use COMEFROM, but due to using such a deficient programming language, had to emulate it with gotos.
  • Gyxi (unregistered)

    This WTF had a very clear purpose and it succeeded.

    It invalidated all previous posts on thedailywtf.

  • Neil (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    And if you are going to return an arbitrary value, 25 o'clock on 7 September 1752 is far better than Now().
    You might find it hard to return an invalid date. Or you might find that the software gets used in a country where the date is in fact valid.
  • (cs) in reply to Neil
    Neil:
    Steve The Cynic:
    And if you are going to return an arbitrary value, 25 o'clock on 7 September 1752 is far better than Now().
    You might find it hard to return an invalid date. Or you might find that the software gets used in a country where the date is in fact valid.
    Are there lots of countries where 25 o'clock is a valid time?
  • (cs) in reply to Steve The Cynic

    So TRWTF is in the video label62 is misaligned, right?

  • (cs) in reply to Tom
    Tom:
    why create 88 labels (with no real name of course) when only one would be enough?
    Because then he could call the project "88 Labels about 44 Women".

    Reno: ran on A-I-X, a prehistoric memory. Cathy: was a Linux-freak she liked that kind of misery. Vicky: had this special way of turning gotos into loops. Camella: couldn't program, and the metre here is the real WTF.

  • Recursive Reclusive (unregistered) in reply to Tom
    Tom:
    Not only this developer used Goto, which is enough to deserve a slow and painful death, but he wasn't even able to use it properly... why create 88 labels (with no real name of course) when only one would be enough?

    The different labels are important for flexibility and future extensions. Right now many labels points to the same code, but when the calendar changes in the future, you might need different code for the different labels.

    It's actually quite brillant.

  • Sexy Hexi (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    Neil:
    Steve The Cynic:
    And if you are going to return an arbitrary value, 25 o'clock on 7 September 1752 is far better than Now().
    You might find it hard to return an invalid date. Or you might find that the software gets used in a country where the date is in fact valid.
    Are there lots of countries where 25 o'clock is a valid time?
    I live in Hexidecimalia where we have rationalized all measurement systems. 256 seconds in an hour, 256 hours in a day. No need for minutes, an enhancement which by itself saves over 17 trillion innocent bits per year.

    Of course those backward countries that still use the metric system need to get with the times. Decimal? Excuse me? Something allegedly logical yet based on a number that can't be cut in quarters? And the length of a meter being based on how long a pendulum has to be to swing in one second -- which in turn is not a decimal measure?

    No, the "SI" metric system is a hopeless unfounded mess. Why any civilized nation still uses it is beyond me.

  • (cs) in reply to Remy Porter
    Remy Porter:
    A developer has 88 problems. Then they say, "I know, I'll use a regex." Now they have 89 problems.

    Judging by the sample, they would then have 176 problems.

  • (cs) in reply to curmudgeon
    curmudgeon:
    why create 88 labels (with no real name of course) when only one would be enough?

    That and the infinite indentation has me think this is generated code.

    I don't think any program would willingly generate code this bad. It's gotta be a human.

  • (cs) in reply to DCRoss
    DCRoss:
    Tom:
    why create 88 labels (with no real name of course) when only one would be enough?
    Because then he could call the project "88 Labels about 44 Women".

    Reno: ran on A-I-X, a prehistoric memory. Cathy: was a Linux-freak she liked that kind of misery. Vicky: had this special way of turning gotos into loops. Camella: couldn't program, and the metre here is the real WTF.

    Sounds like you got a binder full of women.

  • Cap'n Spanky (unregistered)
    If (Else.EndsWith(" TOST")) Then dt = dt.Replace(" TOST", "+13:00")
    I like tost.
  • Joe (unregistered) in reply to Remy Porter
    Remy Porter:
    A developer has 88 problems. Then they say, "I know, I'll use a regex." Now they have 89 problems.
    And soon they have <problem><number="90" /><name="XML" /></problem>
  • Joints (unregistered) in reply to dkf
    dkf:
    Simon Peyote Joints:
    [Goto] does have its place (but mostly only in C).
    It is a primitive used to build control structures. Like many primitives, it's horrible to use it directly. On the other hand, having it lets you built new control structures rather than being stuck with if and while (for, do/while and switch are in many ways syntactic sugar round those two) which, while a set that lets you express any algorithm with enough contortions, are only a fraction of what has been discovered. C doesn't have try/catch/finally (or RAII) so error handling and cleanup are necessarily rather messy. There are a few other fundamental control structures that C doesn't have and which need gotos to model well (e.g., coroutines).

    But TRWTF is when programmers create a vast mess of super-nested conditionals and boolean variables just to avoid a single goto. Yeah, goto can be harmful, but so can the things that people do to avoid it…

    GOTO does not need to be used in modern day languages. Unles s you want to open up a can of worms in your code.

  • (cs) in reply to Remy Porter
    Remy Porter:
    A developer has 88 problems. Then they say, "I know, I'll use a regex." Now they have 89 problems.

    89 problems, but a switch ain't one?

  • noland (unregistered)

    Found the true WTF: There's an indentation error at "label 162"! ;-)

  • linepro (unregistered) in reply to Joints
    Joints:
    dkf:
    Simon Peyote Joints:
    [Goto] does have its place (but mostly only in C).
    It is a primitive used to build control structures. Like many primitives, it's horrible to use it directly. On the other hand, having it lets you built new control structures rather than being stuck with if and while (for, do/while and switch are in many ways syntactic sugar round those two) which, while a set that lets you express any algorithm with enough contortions, are only a fraction of what has been discovered. C doesn't have try/catch/finally (or RAII) so error handling and cleanup are necessarily rather messy. There are a few other fundamental control structures that C doesn't have and which need gotos to model well (e.g., coroutines).

    But TRWTF is when programmers create a vast mess of super-nested conditionals and boolean variables just to avoid a single goto. Yeah, goto can be harmful, but so can the things that people do to avoid it…

    GOTO does not need to be used in modern day languages. Unles s you want to open up a can of worms in your code.

    setjmp longjmp

    Try and handle driver exceptions without them...

  • sagaciter (unregistered) in reply to pscs
    pscs:
    Unless I'm reading it wrong (or it was copy/pasted incorrectly), there's an even bigger WTF

    It never gets to checking for "WSST" or later, because the 'goto label1' bypasses all that

    Three hours gone now and nobody cares.

    Why should they when not even the compiler does?

  • (cs) in reply to Neil
    Neil:
    Steve The Cynic:
    And if you are going to return an arbitrary value, 25 o'clock on 7 September 1752 is far better than Now().
    You might find it hard to return an invalid date. Or you might find that the software gets used in a country where the date is in fact valid.
    In Java, creating a GregorianCalendar with 1752, Sep 7, 25:00 yields: 1752 09 08 01:00:00.000

    Something isn't consistent.

  • Nemo (unregistered) in reply to tweek
    tweek:
    Remy Porter:
    A developer has 88 problems. Then they say, "I know, I'll use a regex." Now they have 89 problems.

    89 problems, but a switch ain't one?

    I don't think his father used a switch on him often enough.

  • (cs) in reply to snoofle
    snoofle:
    Neil:
    Steve The Cynic:
    And if you are going to return an arbitrary value, 25 o'clock on 7 September 1752 is far better than Now().
    You might find it hard to return an invalid date. Or you might find that the software gets used in a country where the date is in fact valid.
    In Java, creating a GregorianCalendar with 1752, Sep 7, 25:00 yields: 1752 09 08 01:00:00.000

    Something isn't consistent.

    You must be using CatholicJava rather than AnglicanJava. The 1752 thing is for the UK and the North American colonies (i.e. the territory now included in Canada and the 13 US founding states).

    Or you might be using SwedishJava, which you can test for by looking at the month of February 1712. If you are using SwedishJava, this month will have 30 days.

    Of course, in no version of Java should the GregorianCalendar object be able to parse a date before 1582.

  • (cs)

    in football, this is called a stretch play.

  • foxyshadis (unregistered) in reply to linepro
    linepro:
    Joints:
    GOTO does not need to be used in modern day languages. Unles s you want to open up a can of worms in your code.

    setjmp longjmp

    Try and handle driver exceptions without them...

    Writing driver code in a modern language would be TRWTF, but I'd imagine someone's done one in Java or .Net (and incorporated the whole runtime into the Kernel) somehow. It's just more enterprisey that way.

  • qbolec (unregistered)

    The name dateTimeFromJavaXml suggest the way the code was generated: they took a java library, serialized result for all possible data into XML and then reverse engineered a VBA version of it.

    That, or "decompiled" it.

  • Herr Otto Flick (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    The problem here is, as hinted at above, that the if/else if/else chain is badly broken, with every other else if having been replaced by a simple if. This leads the code to grossly misbehave, and I'd imagine that it returns Now() most of the time.

    That is not the problem with this code. The problem with this code is that it doesn't use any of the very nice libraries that clever people who think a lot about time have written to handle all these interesting time issues.

  • (cs)
    Tom:
    Anyway, VB.NET is a WTF by itself...

    How original of you to be afraid of the replacement for C syntax.

    dkf:
    Yeah, goto can be harmful, but so can the things that people do to avoid it

    My friends and I compiled a list of the worst words in programming. "Goto" topped the list, just ahead of "robust" and "rich."

    Rick:
    There comes a point in every programmer's life where you find yourself wondering "Can this possibly be the best way to do this? Should it really be this difficult? Am I actually so special and unique that I'm the first person in the history of history to encounter this problem?"

    If you don't know how to wonder, you are not a programmer. Please step back from the keyboard. Now.

    Code smells: http://www.codinghorror.com/blog/2006/05/code-smells.html

    Steve The Cynic:
    Are there lots of countries where 25 o'clock is a valid time?

    Ones with space programs, yes.

    D-Coder:
    I don't think any program would willingly generate code this bad. It's gotta be a human.

    The great thing about programs is that they do exactly what you tell them to do. So if you have a bad human using a program, you're going to get this as a result. Garbage in, garbage out.

    foxyshadis:
    Writing driver code in a modern language would be TRWTF, but I'd imagine someone's done one in Java or .Net (and incorporated the whole runtime into the Kernel) somehow. It's just more enterprisey that way.

    That's not an issue of modern languages, it's just low-level versus high-level languages. We've progressed to the point where most modern languages are high-level, and yes, writing driver code in those is a WTF.

  • C-Derb (unregistered) in reply to chubertdev
    chubertdev:
    D-Coder:
    I don't think any program would willingly generate code this bad. It's gotta be a human.

    The great thing about programs is that they do exactly what you tell them to do. So if you have a bad human using a program, you're going to get this as a result. Garbage in, garbage out.

    WHOOOOOOSH!!!

    I'm pretty sure D-Coder was being sarcastic talking about a program doing things "willingly". Or did they add a compiler option to VB.Net that I'm not aware of?

    Option FreeWill Off
    
  • (cs) in reply to C-Derb
    C-Derb:
    I'm pretty sure D-Coder was being sarcastic talking about a program doing things "willingly". Or did they add a compiler option to VB.Net that I'm not aware of?
    Option FreeWill Off
    

    The technological singularity happened in in 2008. :D

    But yeah, I was agreeing with him. (yes, that can happen on this site)

  • turist (unregistered) in reply to Joints
    Joints:
    dkf:
    But TRWTF is when programmers create a vast mess of super-nested conditionals and boolean variables just to avoid a single goto. Yeah, goto can be harmful, but so can the things that people do to avoid it…

    GOTO does not need to be used in modern day languages. Unles s you want to open up a can of worms in your code.

    Not plain wrong, but definitely not true. It depends a little on your idea of a "modern day language" -- most sensible usage of goto i have seen so far was C. But even in C#, I once had a case where goto made the code much simpler and a lot more legible.

    Rule of thumb "avoid goto" is ok, but "ban goto, no matter what" is stupid.

  • Dazed (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    Are there lots of countries where 25 o'clock is a valid time?
    According to the Javascript Date object, 25 o'clock is a valid time in all countries. As is -1 o'clock.

    Some people should just have been strangled at birth.

  • Nagesh (unregistered) in reply to Dazed
    Dazed:
    Steve The Cynic:
    Are there lots of countries where 25 o'clock is a valid time?
    According to the Javascript Date object, 25 o'clock is a valid time in all countries. As is -1 o'clock.

    Some people should just have been strangled at birth.

    Hindu believe that all lifes are sacred.

  • Dazed (unregistered) in reply to Nagesh
    Nagesh:
    Dazed:
    Steve The Cynic:
    Are there lots of countries where 25 o'clock is a valid time?
    According to the Javascript Date object, 25 o'clock is a valid time in all countries. As is -1 o'clock.

    Some people should just have been strangled at birth.

    Hindu believe that all lifes are sacred.
    Well, I believe that life is sacred too. It's just that I make an exception for mosquitos, cholera bacteria, spammers and the people responsible for Javascript.

  • (cs) in reply to Nemo
    Nemo:
    tweek:
    89 problems, but a switch ain't one?
    I don't think his father used a switch on him often enough.
    s/sw/b/
    Now do you get it?

Leave a comment on “The White Flag”

Log In or post as a guest

Replying to comment #:

« Return to Article