• (cs)
    Alex Papadimoulis:

    if ( ssn[6] <> "0" && ssn[6] <> "1" && ssn[6] <> "2" &&
    ssn[6] <> "3" && ssn[6] <> "4" && ssn[6] <> "5" &&
    ssn[6] <> "6" && ssn[6] <> "7" && ssn[6] <> "8" &&
    ssn[6] <> "9" ) {
    return false;
    }


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

  • frozenfred (unregistered)

    So with 11 return points from this funtion, i bet it's a nightmare to debug!!!

  • (cs)

    Great googly moogly.

    Gigantic googly moogly.

    Immense googly moogly.

    Colossal googly moogly.

    I can hardly believe this.

     

  • zeridon (unregistered)

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

  • (cs)

    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?

  • (cs)

    This obviously comes from a time before regular expressions existed, and when social security numbers had 10 digits in them...

  • (cs) in reply to loneprogrammer
    loneprogrammer:

    How much is too much?


    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.
  • (cs) in reply to zeridon

    From some site I read

    Any SSN conforming to one of the following criteria is an invalid number:

    1. Does not consist of 9 digits
    2. Any field all zeroes (no field of zeroes is ever assigned).
    3. First three digits above 770
    Basically, this just validates numerical accuracy.  I'm sure that is VERY easy to do if the numbers are placed into a character array (1. check the length of the array  2) use regexp for 00 checking 3) ssn[0-2] <= 770

    Seriously, how hard can that be?

  • Brian (unregistered) in reply to christoofar

    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?


  • (cs)

    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.

  • (cs)

    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]

  • DragonSpeed (unregistered) in reply to allanc

    You're kidding right?  I think we've pretty much nailed down the number sequence between 0-9 these days :)

  • DragonSpeed (unregistered) in reply to DragonSpeed

    Anonymous:
    You're kidding right?  I think we've pretty much nailed down the number sequence between 0-9 these days :)

    That was in response to allanc

  • (cs)

    parseInt() anyone? 

    But really, id expect this after "Lesson 2: If Then" but before "Lesson 3: Looping". 

  • Bill Kempf (unregistered) in reply to skicow

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

  • Mario (unregistered) in reply to zeridon
    Anonymous:

    At least here where i live the last 4 digits are computed from the previous your sex and where you were born ...

    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?

  • (cs) in reply to Brian
    Anonymous:
    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?




    Wikipedia, of course.
  • (cs)

    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.

  • (cs) in reply to DZ-Jay

    I'm surprised nobody suggested using JavaScript to solve this WTF.

    Oh wait...

    I know! They should have used XML!

  • (cs)

    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;
    }

  • (cs) in reply to DZ-Jay

    DZ-Jay:
    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.

    WTF is a cow-erkers?!? [;)]

  • Oliver Klozoff (unregistered)

    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) ); }

  • (cs)

    Waaaaaaaaa!  My brain is now fried,  I must clear it with Blood of Satan http://www.drinksmixer.com/drink38.html [;)]

  • (cs)

    Waaaaaaaaa!  My brain is now fried,  I must clear it with Blood of Satan http://www.drinksmixer.com/drink38.html [;)]

  • zeridon (unregistered) in reply to Mario
    Anonymous:
    Anonymous:

    At least here where i live the last 4 digits are computed from the previous your sex and where you were born ...

    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?

    Well i haven't investigated in such detail ... i am not planning on sex change :)

  • Fregas (unregistered)

    oh fuck me.

  • (cs) in reply to cm5400

    cm5400:
    Waaaaaaaaa!  My brain is now fried,  I must clear it with Blood of Satan http://www.drinksmixer.com/drink38.html [;)]

    G'Damn Frickin (UNi)Telligentsystems CommunityServer.  Sorry for the duplicate!

  • (cs) in reply to skicow

    skicow:
    cow-erkers?!?

    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"

  • JD (unregistered)

    Tell me that this isn't true. That you are kidding us.

    Oh my......I don't know whether to screm or cry.

    JD

  • Bill Kempf (unregistered) in reply to rogthefrog
    rogthefrog:

    I'm surprised nobody suggested using JavaScript to solve this WTF.

    Oh wait...

    I know! They should have used XML!



    Uhmm... it was in JavaScript.
  • Dragonmagewtf (unregistered) in reply to Manni
    Manni:

    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;
    }



    Or simply (figuring it is all just a string of digits and isNaN works on ints):
    return ! isNaN(ssn);
  • Bill Kempf (unregistered) in reply to JD
    Anonymous:
    Tell me that this isn't true. That you are kidding us.

    Oh my......I don't know whether to screm or cry.

    JD


    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.
  • (cs) in reply to Bill Kempf
    Anonymous:
    rogthefrog:

    I'm surprised nobody suggested using JavaScript to solve this WTF.

    Oh wait...

    I know! They should have used XML!



    Uhmm... it was in JavaScript.

    The "sarcasm" tag doesn't work in this forum's software.

  • (cs)

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

  • (cs)

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

  • (cs) in reply to JamesCurran
    JamesCurran:

    skicow:
    cow-erkers?!?

    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"

    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.

  • (cs) in reply to skicow
    skicow:
    JamesCurran:

    skicow:
    cow-erkers?!?

    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"

    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.


    You need to read more Dilbert...
  • Bill Kempf (unregistered) in reply to romeogresta
    romeogresta:
    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...


    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.
  • Bill Kempf (unregistered) in reply to Bill Kempf

    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

  • (cs)

    so bad...

    dont have the words...

    left arm is hurting.....


    :S

  • JJ (unregistered)

    here is a simple soulitions  \d{3}-\d{2}-\d{4}

    gee a regualar expression works just fine

     

  • (cs) in reply to skicow

    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

  • dhromed (unregistered) in reply to Rank Amateur
    The actual code used charAt()


    Now prepare for the sound of my body engaging the floor after doing a 90 degree turn with my heels as pivot point.
  • Mikademus (unregistered) in reply to dhromed

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

  • (cs)

    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;
    }

  • (cs) in reply to spotcatbug
    spotcatbug:
    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;
    }

    WTF! This forum software makes no sense!

  • (cs) in reply to JJ

    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";
    }

  • (cs) in reply to Maurits
    if (
        $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";
    }
  • (cs) in reply to Bill Kempf

    Anonymous:
    The actual code used

    Ha, ha, hah, he said "code"...

  • (cs) in reply to Bill Kempf

    Anonymous:
    romeogresta:
    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...


    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.

    Whoops -- I shoulda caught that too. I was in a bit of a rush today .... 

Leave a comment on “Divining the Future Through Numeracy”

Log In or post as a guest

Replying to comment #:

« Return to Article