- 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 guess the devil's in the details.
Ahmm. Seriously, though.. Its amazing the people that call themselves programmers. Here's a clear example of someone who obviously can't seem to grasp the concept, "There must be a better way, Let me take 5 minutes and find it".
Admin
So with 11 return points from this funtion, i bet it's a nightmare to debug!!!
Admin
Great googly moogly.
Gigantic googly moogly.
Immense googly moogly.
Colossal googly moogly.
I can hardly believe this.
Admin
ammm ... wtf really isn't there some rules for these SSN's
At least here where i live the last 4 digits are computed from the previous your sex and where you were born ...
Admin
How do you decide when it's time to quit your company?
We can't all work for Google and if you work long enough, you will eventually find something dumb about your job.
How much is too much?
Admin
This obviously comes from a time before regular expressions existed, and when social security numbers had 10 digits in them...
Admin
Its too much when you can't resist the urge to slap the co-worker that wrote the code, Then it becomes a releif when someone points out their total incompetence and they get fired, or quit.
Admin
From some site I read
Any SSN conforming to one of the following criteria is an invalid number:
Seriously, how hard can that be?
Admin
This actually prompted me to do some reading up about social security.
Check out the Freudian slip I found in question 11 on the official social security FAQ at www.ssa.gov. With all the debate about social security, they might want to fix this.
Q11: Where do I get more information about the Social Security program as it exits today?
Admin
The worst part about this function is that if they ever add a new digit between 0 and 9, they're going to have to change it in every location in this code.
Admin
wow, nice WTF.
Not sure about anyone else but my SSN is only 9 numbers, not 10...so my SSN would fail this check [Y]
Admin
You're kidding right? I think we've pretty much nailed down the number sequence between 0-9 these days :)
Admin
That was in response to allanc
Admin
parseInt() anyone?
But really, id expect this after "Lesson 2: If Then" but before "Lesson 3: Looping".
Admin
That would be my mistake. You type out that mess and see if you don't make a very similar mistake somewhere ;). The original code didn't have this mistake, though it did have other mistakes (multiple).
Admin
As opposed to "the future" or "the present" your sex...so if you have a sex-change operation your SSN changes? Or if you have more or less sex?
Admin
Wikipedia, of course.
Admin
After reading this, I caught myself saying, in a somber voice, loud enough for others to hear, "HOLY MOTHER OF GAWD!". My cow-erkers then stared at me for while.
There is a place in hell, down in the deepest, darkest corners; across the hall from Hitler's, reserved specially for the coder who wrote that.
dZ.
Admin
I'm surprised nobody suggested using JavaScript to solve this WTF.
Oh wait...
I know! They should have used XML!
Admin
Even without the availability of regular expressions, this could easily be reduced to a few lines with the use of a loop and something to test the validity of each character. It's not the optimal solution, I know, but it would vastly reduce the WTF-ness of a function of 60+ repetitive lines. I don't know a lot of Java, but I would imagine this works:
function validateSSN( ssn ) {
var SSNlen = 9;
for(i = 0; i < SSNlen; ++i) {
if (isNaN(ssn[i]) == true) { return false; }
}
return true;
}
Admin
WTF is a cow-erkers?!? [;)]
Admin
function validateSSN(ssn) { return !( (/^(\D|.{0,8}|.{10,}|000......|...00....|.....0000|77[1-9]......|7[8-9][0-9]......|[8-9][0-9][0-9]......)$/).test(ssn) ); }
Admin
Waaaaaaaaa! My brain is now fried, I must clear it with Blood of Satan http://www.drinksmixer.com/drink38.html [;)]
Admin
Waaaaaaaaa! My brain is now fried, I must clear it with Blood of Satan http://www.drinksmixer.com/drink38.html [;)]
Admin
Well i haven't investigated in such detail ... i am not planning on sex change :)
Admin
oh fuck me.
Admin
G'Damn Frickin (UNi)Telligentsystems CommunityServer. Sorry for the duplicate!
Admin
Well, it should be "cow-orkers", and I'm not sure if you were questioning the spelling or the meaning. A "cow-orker" is a "'dumb-as-a-cow' co-worker"
Admin
Tell me that this isn't true. That you are kidding us.
Oh my......I don't know whether to screm or cry.
JD
Admin
Uhmm... it was in JavaScript.
Admin
Or simply (figuring it is all just a string of digits and isNaN works on ints):
return ! isNaN(ssn);
Admin
Quite true, and actually the least WTF in the application. At the beginning of inheriting this mess, the team informed management we could rewrite it from scratch using a maintainable architecture in less than 3 months. They deemed that too long, despite warnings that just fixing the known bugs would take longer. A year later we were still correcting bugs, and for every bug fixed we created at least one new one, usually more like 3 new ones. There was no hope for the code base. Interesting and useful application... at least it would have been if management had allowed us to write it.
Admin
The "sarcasm" tag doesn't work in this forum's software.
Admin
The biggest WTF of all (and nobody noticed it) is that it uses "<>" instead of "!=".
C'mon, does it really can be found is a production system? It's a syntax error. Or it's just the way Alex posted it?
Or it's just a fake post...
Admin
The biggest WTF of all (and nobody noticed it) is that it uses "<>" instead of "!=".
C'mon, does it really can be found in a production system? It's a syntax error. Or it's just the way Alex posted it?
Or it's just a fake post...
Admin
I knew what he was trying to convy - I was just being a smart ass. [:P]
To tell you the truth I had never seen cow-orkers used as a phrase but I figured out the meaning.
Admin
You need to read more Dilbert...
Admin
None of the above. He posted it as I sent it to him, and I wrote that mess by hand in a hurry. My original post had a disclaimer about this, which Alex did remove, but that doesn't mean I'm any less guilty of being lazy here. But the code illustrates the "algorithm" that was present in the original code quite accurately. Not a fake post, and it was in production when my team inherited the mess.
Admin
BTW, Alex also added the part about converting to an array. The actual code used charAt(), but I wasn't about to type that all over the place :P
Admin
so bad...
dont have the words...
left arm is hurting.....
:S
Admin
here is a simple soulitions \d{3}-\d{2}-\d{4}
gee a regualar expression works just fine
Admin
Cow-orkers are dumb as a cow? I would never denigrate cows by comparing their intelligence to the "developers" who created such WTFs.
A cow-orker is one who orks a cow ...which is very rude.
--RA
Admin
Now prepare for the sound of my body engaging the floor after doing a 90 degree turn with my heels as pivot point.
Admin
I've always believed that "dropping one's jaw" is just an expression. But when reading that code, for the first time in my life, I realised my jaw was indeed hanging slack open...
Hawt damn, how can (1) anyone write that code and not realise how silly it is, and (2) anyone else actually copy and use it, thus giving it implicit approval?!
Admin
I think this would be more readable:
function validateSSN(ssn)
{
if (ssn == "001001001")
return true;
if (ssn == "001001002")
return true;
if (ssn == "001001003")
return true;
if (ssn == "001001004")
return true;
if (ssn == "001001005")
return true;
[SNIP!]
if (ssn == "770999997")
return true;
if (ssn == "770999998")
return true;
if (ssn == "770999999")
return true;
if (ssn == "770999998")
return true;
return false;
}
Admin
WTF! This forum software makes no sense!
Admin
Perl solution:
if (
$ssn !~ /^(\d{3})-(\d{2})-(\d{4})$/ or
$1 eq "000" or
$2 eq "00" or
$3 eq "0000"
)
{ die "$ssn not correctly formatted SSN";
}
Admin
$ssn !~ /^(\d{3})-(\d{2})-(\d{4})$/ or
$1 eq "000" or
$1 > 770 or # missed this one
$2 eq "00" or
$3 eq "0000"
)
{ die "$ssn not correctly formatted SSN";
}
Admin
Ha, ha, hah, he said "code"...
Admin
Whoops -- I shoulda caught that too. I was in a bit of a rush today ....