Comment On The Ultimate State Selector

One of the fundamental axioms of software development — #9 on the list, actually — is that "there is always a better way." This holds that there is no such thing as Perfect Code, only Good Code which is appropriately correct, appropriately optimized, and appropriately documented for the situation at hand. On the other hand, a lesser-known axioms (#1873, for those keeping count) is that "there is always a worse way." No matter how bad a particular block of code may seem... someone, somewhere, somehow will develop something even worse. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: The Utlimate State Selector

2009-09-09 09:01 • by ParkinT
if ($Post == 'First')
{
$Post.delete();
} elseif ( $Post == 'Fist!')
{
$Post.delete();
} elseif { $Post == 'Brillant' )
{
...snip 1,234,877,980,998,234,999,564,090,000 lines of code
}

Re: The Utlimate State Selector

2009-09-09 09:11 • by Federico (unregistered)
#!/bin/sh

for char in W T F '!'; do
if "$char" == 'W'; then
echo 'W'
elif "$char" == 'T'; then
echo 'T'
elif "$char" == 'F'; then
echo 'F'
elif "$char" == '!'; then
echo '!'
fi
done

CAPTCHA: pecus: pecus bill?

Re: The Utlimate State Selector

2009-09-09 09:11 • by AussieMan (unregistered)
"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.

Re: The Utlimate State Selector

2009-09-09 09:11 • by ounos

<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?

Re: The Utlimate State Selector

2009-09-09 09:11 • by eViLegion (unregistered)
I particularly like the maintainability of this example.

Re: The Utlimate State Selector

2009-09-09 09:11 • by pjt33
He should be grateful that they didn't have a drop-down to select the country you live in.

Re: The Utlimate State Selector

2009-09-09 09:12 • by Ville (unregistered)
I don't understand why the bigger problem wasn't fixed at the same time. It would've taken maybe 2 minutes to fix it, after all.

Re: The Utlimate State Selector

2009-09-09 09:12 • by eViLegion (unregistered)
284692 in reply to 284688
Because Texas is full of empty space?

Re: The Utlimate State Selector

2009-09-09 09:12 • by pjt33
284693 in reply to 284688
ounos:

<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?

Because everything's bigger in Texas.

Re: The Utlimate State Selector

2009-09-09 09:13 • by @Deprecated (unregistered)
Obviously the WTF is that the coder created an input to select a province, and then filled it with 55 US states.

Re: The Utlimate State Selector

2009-09-09 09:14 • by Yazeran (unregistered)
Oh My God!!!

Initially I was thinking that they did some regexp or something after creating that 'select' string and somehow bungled that (not so hard when doing regexps), but then I scrolled down and saw the second if statment (My brain likely glossed over the first one to save my sanity) and then I understood....

Yours Yazeran

Plan: To go to Mars one day with a hammer

Re: The Utlimate State Selector

2009-09-09 09:16 • by Federico (unregistered)
The RWTF is Server Guys: didn't they notice that the application contained far too many lines of code?

Re: The Utlimate State Selector

2009-09-09 09:16 • by Bri (unregistered)
284698 in reply to 284688
You are incorrectly assuming the state selector was created via copy-paste. It was hand-written. This is the kind of code you get if you pay bonuses based on LOC.

Re: The Utlimate State Selector

2009-09-09 09:18 • by ugh (unregistered)
I was sick in my mouth.

Re: The Utlimate State Selector

2009-09-09 09:18 • by Code Dependent
Shouldn't Mr. Zimmer forget about playing with code and get busy running The Men's Wearhouse?

Re: The Utlimate State Selector

2009-09-09 09:22 • by t-bone
284702 in reply to 284688
--
Re: The Utlimate State Selector
2009-09-09 09:11 • by ounos

<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?
--

copy paste programming

copy paste the previous block of options, remove selected="selected" and leave the space that was there without caring too much

Re: The Utlimate State Selector

2009-09-09 09:23 • by highphilosopher (unregistered)
284703 in reply to 284698
I disagree, this looks like copy-paste disease to me.

Re: The Utlimate State Selector

2009-09-09 09:32 • by Anon (unregistered)
284704 in reply to 284688
ounos:

<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?


WTF? Real The What The Fuck? That's TRWTF.

Re: The Utlimate State Selector

2009-09-09 09:39 • by Code Dependent
284705 in reply to 284704
Anon:
ounos:
That's the RTWTF. Texas' option got an extra space. WHY?
WTF? Real The What The Fuck? That's TRWTF.
No, look, he put "the" in front of it. It's "Real True WTF".

Re: The Utlimate State Selector

2009-09-09 09:49 • by Wulf (unregistered)
284706 in reply to 284687
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.


Imagine if this were to go multi-national,LOC bonus anyone?

Re: The Utlimate State Selector

2009-09-09 09:53 • by JP (unregistered)
The real WTF is the 'Utlimate' in the title of this article. A little proof reading before posting perhaps?

Re: The Utlimate State Selector

2009-09-09 09:59 • by dtobias
If it's in Perl, I'd do it like:

%statesel = ();
$statesel{$state} = " selected='selected'";
$states = "<select name='usr_state'>
<option value='AL'$statesel{'AL'}>AL - Alabama</option>
<option value='AK'$statesel{'AK'}>AK - Alaska</option>
[snip rest of states]
</select>";

(note that I use "value" attributes so that the variable gets set to the state code without the descriptive text; more useful for database storage and address printing this way; and I call a state a state instead of a province; damn Canadians!)

Re: The Utlimate State Selector

2009-09-09 10:01 • by freibooter (unregistered)
284709 in reply to 284707
JP:
The real WTF is the 'Utlimate' in the title of this article.


Really? I think the current title is quite brillant!

Re: The Utlimate State Selector

2009-09-09 10:01 • by Mott555 (unregistered)
Wow, it hurts to read....really really bad.

Re: The Utlimate State Selector

2009-09-09 10:04 • by Brain (unregistered)
284711 in reply to 284707
JP:
The real WTF is the 'Utlimate' in the title of this article. A little proof reading before posting perhaps?

Ultimate properly describes this on this site. I'm looking forward to 5 years from now seeing one even worse and going into a gran mal seizure.

Re: The Utlimate State Selector

2009-09-09 10:05 • by Mark Jonson (unregistered)
TRWTF is that Arkansas (AK) is listed before Arizona (AZ) every time.

Re: The Utlimate State Selector

2009-09-09 10:06 • by Rocco (unregistered)
284713 in reply to 284710
else if ($province == "AR - Arkansas") {
$provinces = "<select name='usr_province'>
<option>AL - Alabama</option>
<option>AK - Alaska</option>
<option selected='selected'>AZ - Arizona</option>


So if I move to Arkansas, should I send my stuff to Arizona?

Re: The Utlimate State Selector

2009-09-09 10:07 • by Mark Jonson (unregistered)
284714 in reply to 284712
Sorry, made a few errors. AK is Alaska, AR is Arkansas. And TRTRWTF is that AZ was actually listed before AR.

Re: The Utlimate State Selector

2009-09-09 10:09 • by SR (unregistered)
284715 in reply to 284711
freibooter:
JP:
The real WTF is the 'Utlimate' in the title of this article.


Really? I think the current title is quite brillant!

Brain:
Ultimate properly describes this on this site. I'm looking forward to 5 years from now seeing one even worse and going into a gran mal seizure.


I think "ultimate" is a great description. "Utlimate" is not so good.

Re: The Utlimate State Selector

2009-09-09 10:11 • by Anonymous (unregistered)
Oh come on, you're bullshitting us!! Aren't you? Please? How do you screw up something so simple so badly? There really is only one explanation: this was an equal opportunities employee on work placement as part of their "CS for the Mentally Handicapped" course. It just has to be.

[Post attempt #3]

Re: The Utlimate State Selector

2009-09-09 10:12 • by SR (unregistered)
284717 in reply to 284714
Mark Jonson:
And TRTRWTF is that AZ was actually listed before AR.


I'm no American but isn't Arizona (AZ) supposed to come before Arkansas (AR)?

CAPTCHA: had a really nice pink and green background.

Re: The Utlimate State Selector

2009-09-09 10:14 • by pfzema
284718 in reply to 284716
Anonymous:
There really is only one explanation


Apart from Paula Bean, you mean.

Re: The Utlimate State Selector

2009-09-09 10:16 • by Niels (unregistered)
284719 in reply to 284688

<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.

Re: The Utlimate State Selector

2009-09-09 10:16 • by Steve Syfuhs (unregistered)
284720 in reply to 284687
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.


Same in Canada. Code looks similar to another app I've seen... Except we spell our variables with an 'ou' than 'o'.

Re: The Utlimate State Selector

2009-09-09 10:18 • by dkf
284721 in reply to 284717
SR:
I'm no American but isn't Arizona (AZ) supposed to come before Arkansas (AR)?
Depends on whether you're sorting by state name or state code, silly.

(BTW, did the author of this code ever stop to look at it and think "there must be a better way"? It's even possible to improve it without using a loop, for goodness' sake!)

Re: The Utlimate State Selector

2009-09-09 10:19 • by Rodnas (unregistered)
Maybe this code was written by the son or daugther of Paula Bean. He or she should be the right age now to produce this code.


Good title for a horror movie too: "Son of Paula Bean"

Re: The Utlimate State Selector

2009-09-09 10:22 • by MadtM (unregistered)
284723 in reply to 284703
highphilosopher:
I disagree, this looks like copy-paste disease to me.


Oh the humanity...

Re: The Utlimate State Selector

2009-09-09 10:28 • by SR (unregistered)
284724 in reply to 284721
dkf:
Depends on whether you're sorting by state name or state code, silly.


Exactly. You can argue it either way - hardly a WTF (especially not in that code sample.

dkf:
(BTW, did the author of this code ever stop to look at it and think "there must be a better way"? It's even possible to improve it without using a loop, for goodness' sake!)


I reckon the original coder did, but only after the Emperor of Canada (yesterday's WTF) fired him.

Re: The Utlimate State Selector

2009-09-09 10:28 • by Pauldy (unregistered)
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.

Re: The Utlimate State Selector

2009-09-09 10:31 • by Rebecca (unregistered)
This makes my brain hurt in so many ways.

I read the intro paragraph, totally missed the first 'if', read the first state list.... couldn't find the wtf.... reread it... still didn't see it.... scrolled down... and then it hit me.

My jaw literally dropped.

captcha: vulputate. Teehee, that sounds dirty.

Re: The Utlimate State Selector

2009-09-09 10:33 • by SlapNut (unregistered)
So North Dakota is no longer a state?

Re: The Utlimate State Selector

2009-09-09 10:33 • by SlapNut (unregistered)
So North Dakota is no longer a state?

Re: The Utlimate State Selector

2009-09-09 10:35 • by Anguirel
284729 in reply to 284725
Pauldy:
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.


Database? It probably submits via mailto to a group of people who hand edit an Excel spreadsheet stored on a shared drive somewhere.

Re: The Utlimate State Selector

2009-09-09 10:35 • by luis.espinal
284730 in reply to 284721
dkf:
SR:
I'm no American but isn't Arizona (AZ) supposed to come before Arkansas (AR)?
Depends on whether you're sorting by state name or state code, silly.

(BTW, did the author of this code ever stop to look at it and think "there must be a better way"? It's even possible to improve it without using a loop, for goodness' sake!)


I've actually met "code typists" (can't bring myself to call them developers or coders) who are actually incapable of stopping and reflect on the crap they are typing.

I've never seen anything that bad (in number of LOC), but I've seen vulgarities just as viscerally bad that makes you wanna claw your eyes out and curl into a ball under a running shower. And they look at that type of code and they don't think anything about it.

They just don't get it, and I still can't get how the hell they graduate from college, get a job... and stay on that job producing that type of crap.

Re: The Utlimate State Selector

2009-09-09 10:38 • by Code Dependent
284731 in reply to 284719
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.

Re: The Utlimate State Selector

2009-09-09 10:40 • by monkey (unregistered)
A great way to work if you get paid by the line!

Re: The Utlimate State Selector

2009-09-09 10:43 • by fennec
284734 in reply to 284708
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).

Re: The Utlimate State Selector

2009-09-09 10:45 • by Gieron
TRWTF is that Northern Mariana Islands is missing.

And North Dakota.

Re: The Utlimate State Selector

2009-09-09 10:47 • by 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

Re: The Utlimate State Selector

2009-09-09 10:49 • by SR (unregistered)
284737 in reply to 284735
Gieron:
TRWTF is that Northern Mariana Islands is missing.

And North Dakota.


Given the effort of updating this trainwreck, they'd stay missing til someone was kind enough to rewrite it
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment