• Anon (unregistered) in reply to Pauldy
    Pauldy:
    ZOMG so many WTFs head asplodes with "The Utlimate State Selector", state provinces states alphabetized by the code instead of the name and writting one module of 30,000 lines and taking the week off. I'm anxious now to see the module that takes the return value from the form and converts it into something that is stored in the database.

    I thinking it's stored in a database table with 50+ columns

  • (cs)

    You could optimize this code by making is a case/switch instead of if-else.

  • rqb (unregistered)

    all pirates come from ARRRkansas

  • IgglePiggle (unregistered)

    Jeez. My ears are bleeding. I hope that the developer was put out of his colleagues' misery.

  • Migala (unregistered) in reply to ubersoldat
    ubersoldat:
    It would be funny to see the face of the reviewer of this code when submiting to [cvs|svn|git] and getting the email with the diff
    • 5000 loc
    • 10 loc

    It's funny how you think an organization with code like this has a code reviewer.

  • (cs) in reply to @Deprecated
    @Deprecated:
    Obviously the WTF is that the coder created an input to select a province, and then filled it with 55 US states.
    Thanks, Mr. President!
  • (cs)

    Worst. Code. Ever.

    I sat here stupified, mouth agape, and mind blank for about a minute before I could think to find the Add Comment link.

    The site has earned its name with this one.

    WHAT THE FRAK!?

  • (cs) in reply to SlapNut
    SlapNut:
    So North Dakota is no longer a state?
    What about East Dakota?
  • jbinaz (unregistered) in reply to ounos
    ounos:
    That's the RTWTF. Texas' option got an extra space. WHY?

    Because everything is bigger in Texas.

  • (cs) in reply to JP
    The real WTF is the 'Utlimate' in the title of this article. A little proof reading before posting perhaps?

    Even with everything Alex has seen, he was still in shock and barely able to find the "Post" button.

  • bored (unregistered)

    Makes me feel warm and fuzzy inside about the code that I have written today. I am NOT the worst now yaaaaaaaaaaaaay.

    x3 submit

    Captcha: wisi - I went to take a wisi and got it on the toilet seat.

  • Patrick (unregistered)

    Looks like PHP, so I'd fix it like: $sn = 'sel'.substr($state, 0, 2); $$sn = ' selected="selected"'; $states = <<<END <select name="usr_state">

    <option $selAL>AL - Alabama</option> <option $selAK>AK - Alaska</option> [snip rest of states] </select> END; Can't use the `value` attribute without fixing what processes/stores the value, and that could be a lot of work (or not much at all, depends how it's being used).

    The more important WTF is that you can't say <select value="AK"> in HTML. That would be really useful because, if PHP's error check is set to strict, it will send warnings about the remaining undeclared identifiers and you'd need to default them all to blank.

  • ih8u (unregistered) in reply to freibooter
    freibooter:
    JP:
    The real WTF is the 'Utlimate' in the title of this article.

    Really? I think the current title is quite brillant!

    The article explains that there is ALWAYS a worse way to code. The 'ultimate' in the title means the last, implying that this is the worst way to code the state selector.

    The article is contradicting itself ... wait this is the daily WTF where the articles are ... nevermind.

  • JoC (unregistered)

    Having lived in AR, I figured it was just some simple AR/AZ misunderstanding. There are a whole lot of people out there that think AR = Arizona.

    Most of them could probably piece together better code if they had to.

  • (cs) in reply to Patrick
    Patrick:
    The more important WTF is that you can't say <select value="AK"> in HTML.
    Ever needed a "<select multiple>" ?
  • Organizer (unregistered) in reply to Mark Jonson
    Mark Jonson:
    Sorry, made a few errors. AK is Alaska, AR is Arkansas. And TRTRWTF is that AZ was actually listed before AR.

    SELECT STATE.CODE, STATE.NAME FROM STATE_PROVINCE AS STATE ORDER BY STATE.NAME;

    It shouldn't have mattered! The states are a data-set and should be in a database (SQL, a flat-file, an array). That database is responsible for the ordering.

    Also, the <option>ST - State Name</option> blocks don't store the keys in value attributes. That would improve the system's performance.

  • Ken Hagan (unregistered) in reply to SR
    SR:
    Given the effort of updating this trainwreck, they'd stay missing til someone was kind enough to rewrite it

    Oh, no. What would happen is that they'd be added, but not to all the branches, so it would be possible (say) to move to these places from Alabama, but then be unable to move back. Over time, as people attempted to fix this bug by randomly hacking about, the program would evolve into a "routing problem". Then someone with half a clue (not a whole one, mind) would recognise this and try to build an implementation of OSPF on top of the code.

    Remember, there really is no lower limit to code quality.

  • (cs)

    My brain refuses it...

    Couldn't it be just bad generated code, or ...something... anything ! please !?

  • Patrick (unregistered) in reply to Mithfindel
    Mithfindel:
    Patrick:
    The more important WTF is that you can't say <select value="AK"> in HTML.
    Ever needed a "<select multiple>" ?
    Yes.

    Find a way. Or I'll do it for you:

    <select multiple value="A|B|C" [delimiter="|"]>

    That was easy, wasn't it?

  • monkeyPushButton (unregistered) in reply to JP
    JP:
    The real WTF is the 'Utlimate' in the title of this article. A little proof reading before posting perhaps?
    It's written that way so that "frist" posters can read it.
  • Murdog (unregistered)

    OHHH yes, copy paste disease. I once caught a coder red handed doing that. Used the difference function in Source Gear Vault to show that the new section of code from one of his check ins was EXACTLy the same as a piece of code else where in the system.

    When I asked him about this, he at first said it wasn't him, but Vault does not lie even though he does!

  • steevie (unregistered) in reply to ih8u

    There is no "uLtimate" in the title (copy&paste&spellcheck it!), so don't worry, in another 5 years there will definitely be Yet-Another-Even-Worse-CodeSOD.

  • (cs)

    The real thing that scares me is that someone wrote this and said yes, 3000+ lines of code to select one of ~50 items from a list is a perfectly reasonable solution!

    Siiiiiiigh.

  • Me (unregistered)

    Guys... I think this means Alex is gonna close the site. That's it, we're done here. The Ultimate WTF has been found.

  • tagno25 (unregistered) in reply to Patrick
    Patrick:
    Looks like PHP, so I'd fix it like: $sn = 'sel'.substr($state, 0, 2); $$sn = ' selected="selected"'; $states = <<<END <select name="usr_state"> <option $selAL>AL - Alabama</option> <option $selAK>AK - Alaska</option> [snip rest of states] </select> END; Can't use the `value` attribute without fixing what processes/stores the value, and that could be a lot of work (or not much at all, depends how it's being used).

    The more important WTF is that you can't say <select value="AK"> in HTML. That would be really useful because, if PHP's error check is set to strict, it will send warnings about the remaining undeclared identifiers and you'd need to default them all to blank.

    I would fix it like this if it is indeed PHP.

    $states=array("AL - Alabama", "AK - Alaska", "AZ - Arizona", "AR - Arkansas", "AA - Armed Forces America", "AE - Armed Forces Other Areas", "AP - Armed Forces Pacific", "CA - California", "CO - Colorado", "CT - Connecticut", "DE - Delaware", "DC - District of Columbia", "FL - Florida", "GA - Georgia", "GU - Guam", "HI - Hawaii", "ID - Idaho", "IL - Illinois", "IN - Indiana", "IA - Iowa", "KS - Kansas", "KY - Kentucky", "LA - Louisiana", "ME - Maine", "MD - Maryland", "MA - Massachusetts", "MI - Michigan", "MN - Minnesota", "MS - Mississippi", "MO - Missouri", "MT - Montana", "NE - Nebraska", "NV - Nevada", "NH - New Hampshire", "NJ - New Jersey", "NM - New Mexico", "NY - New York", "NC - North Carolina", "ND - North Dakota", "OH - Ohio", "OK - Oklahoma", "OR - Oregon", "PA - Pennsylvania", "PR - Puerto Rico", "RI - Rhode Island", "SC - South Carolina", "SD - South Dakota", "TN - Tennessee", "TX - Texas", "VI - U.S. Virgin Islands", "UT - Utah", "VT - Vermont", "VA - Virginia", "WA - Washington", "WV - West Virginia", "WI - Wisconsin", "WY - Wyoming");

    $provinces = "";

    foreach ($states as $select) { if ($province == $select) { $provinces.="<option selected='selected'>$select</option>"; } else { $provinces.="<option>$select</option>"; } }

  • (cs) in reply to fennec
    fennec:
    dtobias:
    If it's in Perl, I'd do it like:

    Why wouldn't you just set use, I dunno, a loop? (I ask because you seem quasiserious and your code's not really bad enough to be funny.) Or if you want good perl...

    %states = (AL => 'Alabama', ...);
    $selector = join "\n",
      "<select>", 
      (map { sprintf ('<option value="%s"%s>%s - %s</option>',
                 $_, 
                 $_ eq $selected ? ' selected="selected"' : '',
                 $_, 
                 $states{$_},
      )} sort keys %states),
      "</select>";
    

    See? Perl is a pretty language! (assuming you can get past a few $%_s without OMGing too much).

    FTFY.

    Anyway you can't tell me Perl is a "pretty" language with nonsense like unquoted strings as array keys but not array values. I won't even get into $_.

    Post attempt 4. This comment system ever going to be fixed?

  • Anonymous (unregistered)

    Why are people posting alternative solutions to this train-wreck code? This is TDWTF, we can all do better than this shit else we wouldn't even be here. By posting a solution you are basically saying "look at me, I'm smarter than a dribbling retard".

  • Plz Send Me The Code (unregistered)

    Maybe this could be the next contest...create a worse state selector.

    captcha: dolor, like dolor de cabeza

  • SR (unregistered) in reply to Me
    Me:
    Guys... I think this means Alex is gonna close the site. That's it, we're done here. The Ultimate WTF has been found.

    You're right. If this is ever out-WTFed you can reach me via rehab.

  • Loopy (unregistered) in reply to fennec
    fennec:
    dtobias:
    If it's in Perl, I'd do it like:

    Why wouldn't you just set use, I dunno, a loop? (I ask because you seem quasiserious and your code's not really bad enough to be funny.) Or if you want good perl...

    %states = (AL => 'Alabama', ...);
    $selector = join "\n",
      "<select>", 
      (map { sprintf ('<option value="%s"%s>%s - %s</option>',
                 $_, 
                 $_ eq $selected ? ' selected' : '',
                 $_, 
                 $states{$_},
      )} sort keys %states),
      "</select>";
    

    See? Perl is a pretty language! (assuming you can get past a few $%_s without OMGing too much).

    I might use a hash and a map instead of a loop. But I dunno, that's just me.

  • Loopy (unregistered) in reply to @Deprecated
    @Deprecated:
    Obviously the WTF is that the coder created an input to select a province, and then filled it with 55 US states.
    Last time I looked, there were only 50 states.
  • jhkjh (unregistered)

    i been thinking and thinking about what could possibly be the wtf (besides the bug of course) and just couldn't figure it out. Then it dawned on me.. DUHH he is using an if/else instead of using a switch case statement. What a moron!

  • (cs) in reply to Anonymous
    Anonymous:
    Why are people posting alternative solutions to this train-wreck code? This is TDWTF, we can all do better than this shit else we wouldn't even be here. By posting a solution you are basically saying "look at me, I'm smarter than a dribbling retard".
    FTW
  • Calli Arcale (unregistered) in reply to Loopy
    Loopy:
    I might use a hash and a map instead of a loop. But I dunno, that's just me.

    The count of things that are better than this solution approaches infinity.

  • TimG (unregistered) in reply to Steve Syfuhs
    Steve Syfuhs:
    Same in Canada. Code looks similar to another app I've seen... Except we spell our variables with an 'ou' than 'o'.
    Don't be ridiculous. There's no 'o' in 'variables'.
  • Mr Dribbles (unregistered) in reply to Anonymous
    Anonymous:
    Why are people posting alternative solutions to this train-wreck code? This is TDWTF, we can all do better than this shit else we wouldn't even be here. By posting a solution you are basically saying "look at me, I'm smarter than a dribbling retard".
    You insensitive clod!
  • NutDriverLefty (unregistered) in reply to Loopy
    Loopy:
    Last time I looked, there were only 50 states.

    50 states, one district, and four territories.

  • Brendan (unregistered) in reply to lolwtf

    Hi,

    lolwtf:
    Post attempt 4. This comment system ever going to be fixed?

    What makes you think the code from the article came from the comment system? :-)

    Capcha: damnum - an injury suffered by male bicyclists.

  • Buddy (unregistered) in reply to Loopy
    Loopy:
    Last time I looked, there were only 50 states.

    In this context, «States» also refers to US protectorates, District of Columbia, and APO/FPO. (I'm guessing you know this, but are just being clever‽)

    ⅖ of f⁂-all is still f⁂-all…

  • J. Random PMP (unregistered)

    Damn...I'm a Project Manager, and even I can cobble together better code than that!

  • Buddy (unregistered) in reply to TimG
    TimG:
    Don't be ridiculous. There's no 'o' in 'variables'.

    I see one in the 'b' - at least in the font I'm using.

  • Tom Vollerthun (unregistered)

    The bug was obviously this line: <option>LA - Louisiana/option>

  • Bim Job (unregistered) in reply to Code Dependent
    Code Dependent:
    Niels:
    <option>TN - Tennessee</option> <option >TX - Texas</option> <option>VI - U.S. Virgin Islands</option> <option>UT - Utah</option>
    That's the RTWTF. Texas' option got an extra space. WHY?
    That's the space they need to keep the Bush family in.
    No, the space we plan to keep Dubya in is the Walls Unit in Huntsville.
    Is it mean of me to hope that the Walls Unit is where they put the Nazis who weren't very good at rocket science?

    Or should I just stick to my erotic dreams about Nurse Ratched and the peculiar use of cattle-prods with respect to feeble Yalie boys who can't even be bothered to sign up and defend their country?

  • me (unregistered) in reply to ounos

    Because everything is bigger in Texas. Duh.

  • (cs) in reply to Bim Job
    Bim Job:
    Code Dependent:
    Niels:
    <option>TN - Tennessee</option> <option >TX - Texas</option> <option>VI - U.S. Virgin Islands</option> <option>UT - Utah</option>
    That's the RTWTF. Texas' option got an extra space. WHY?
    That's the space they need to keep the Bush family in.
    No, the space we plan to keep Dubya in is the Walls Unit in Huntsville.
    Is it mean of me to hope that the Walls Unit is where they put the Nazis who weren't very good at rocket science?

    Or should I just stick to my erotic dreams about Nurse Ratched and the peculiar use of cattle-prods with respect to feeble Yalie boys who can't even be bothered to sign up and defend their country?

    Here you go.

    Look, Alex, just because my entire post is a url, that doesn't make it spam. Try to get a grasp of the term "filter".

  • Jay (unregistered) in reply to TimG
    TimG:
    Steve Syfuhs:
    Same in Canada. Code looks similar to another app I've seen... Except we spell our variables with an 'ou' than 'o'.
    Don't be ridiculous. There's no 'o' in 'variables'.

    He's referring to the "ou" in "OUr variables". Apparently he thinks that Yankees spell it "or variables".

  • Jay (unregistered) in reply to AussieMan
    AussieMan:
    "It was an easy fix... but it certainly didn't solve the bigger problem."
    The problem is America has too many states. Australia is easier to maintain.

    I agree. I think we should take immediate steps to solve this problem by expelling Massachusetts, New York, Illinois, and California from the union. Let them unite with France. Then we'd all be happier.

  • lImbus (unregistered)

    Must be situations like this (at 4h AM) that make people think they need to write code that generates such Frankenscripts.

  • dew|frost (unregistered)

    Simply unbelievable. I can't believe it. Please tell me it isn't true. ...would you?

  • David (unregistered)

    TRWTF is that entering states using a drop-down is an annoyance to the user, and poor usability:

    Jakob Nielsen:
    Making users suffer a drop-down menu to enter state abbreviations is one of many small annoyances that add up to a less efficient, less pleasant user experience. It's worth fixing as many of these usability irritants as you can.
    Link: (BBCode URL Tag failed?) http://www.useit.com/alertbox/annoyances.html

Leave a comment on “The Ultimate State Selector”

Log In or post as a guest

Replying to comment #:

« Return to Article