- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I thinking it's stored in a database table with 50+ columns
Admin
You could optimize this code by making is a case/switch instead of if-else.
Admin
all pirates come from ARRRkansas
Admin
Jeez. My ears are bleeding. I hope that the developer was put out of his colleagues' misery.
Admin
It's funny how you think an organization with code like this has a code reviewer.
Admin
Admin
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!?
Admin
Admin
Because everything is bigger in Texas.
Admin
Even with everything Alex has seen, he was still in shock and barely able to find the "Post" button.
Admin
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.
Admin
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.
Admin
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.
Admin
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.
Admin
Admin
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.
Admin
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.
Admin
My brain refuses it...
Couldn't it be just bad generated code, or ...something... anything ! please !?
Admin
Find a way. Or I'll do it for you:
<select multiple value="A|B|C" [delimiter="|"]>
That was easy, wasn't it?
Admin
Admin
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!
Admin
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.
Admin
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.
Admin
Guys... I think this means Alex is gonna close the site. That's it, we're done here. The Ultimate WTF has been found.
Admin
I would fix it like this if it is indeed PHP.
Admin
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?
Admin
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".
Admin
Maybe this could be the next contest...create a worse state selector.
captcha: dolor, like dolor de cabeza
Admin
You're right. If this is ever out-WTFed you can reach me via rehab.
Admin
Admin
Admin
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!
Admin
Admin
The count of things that are better than this solution approaches infinity.
Admin
Admin
Admin
50 states, one district, and four territories.
Admin
Hi,
What makes you think the code from the article came from the comment system? :-)
Capcha: damnum - an injury suffered by male bicyclists.
Admin
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…
Admin
Damn...I'm a Project Manager, and even I can cobble together better code than that!
Admin
I see one in the 'b' - at least in the font I'm using.
Admin
The bug was obviously this line: <option>LA - Louisiana/option>
Admin
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?
Admin
Because everything is bigger in Texas. Duh.
Admin
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".
Admin
He's referring to the "ou" in "OUr variables". Apparently he thinks that Yankees spell it "or variables".
Admin
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.
Admin
Must be situations like this (at 4h AM) that make people think they need to write code that generates such Frankenscripts.
Admin
Simply unbelievable. I can't believe it. Please tell me it isn't true. ...would you?
Admin
TRWTF is that entering states using a drop-down is an annoyance to the user, and poor usability:
Link: (BBCode URL Tag failed?) http://www.useit.com/alertbox/annoyances.html