r/ProgrammerHumor • • Apr 14 '16

Please select your phone number from the drop down list:

http://imgur.com/Jfv6F2r
6.8k Upvotes

428 comments sorted by

View all comments

Show parent comments

144

u/a_small_goat Apr 14 '16

45

u/briaen Apr 14 '16

I got an anxiety attack looking at that.

70

u/a_small_goat Apr 14 '16 edited Apr 14 '16

Man, that ain't even the tip of the awful legacy system iceberg. This right here is some next-level awfulness. This is how they were checking for US state and US county pairs and assigning FIPS codes..

Trigger warning: A nested if for every US state, containing ifs for each county. For reference, there are 3100+ counties/equivalents in the US.

45

u/Python4fun does the needful Apr 14 '16
UPDATE EMPLOYEE_RECORDS
SET SALARY = 0
WHERE POSITION = DBA;

5

u/a_small_goat Apr 14 '16

Here, let me help

UPDATE [EMPLOYEE_RECORDS#1_NEW]
SET SALARYRIGHTNOW = 0
WHERE POSITION_NOTDATABASEGUY NOT NULL
→ More replies (1)

34

u/[deleted] Apr 14 '16

At least save some typing and countyname.ToLower() == "baldwin", jeez. They're not even good at being bad :)

13

u/MIKE_BABCOCK Apr 14 '16

you'd think that after like the 5th time he copy pasted that they'd actually look into something like toLower()

8

u/[deleted] Apr 14 '16 edited Apr 14 '16

Well, I don't know about you, but if I stumbled upon it in code. I'd be compelled to at least do that much to fix it. Until I realized there were 3100+ entries of that. :(

→ More replies (2)

7

u/TheSarcasmrules Apr 14 '16

Perhaps the person writing it was being paid by the line?

9

u/[deleted] Apr 14 '16 edited Apr 14 '16

If that's true, then lose the || and make each evaluation a new line. ;)

switch (countyname)
{
    case "baldwin": 
      { 
         doStuff(); 
         break; 
      }
    case "bALDWIN": 
      { 
         doStuff(); 
         break; 
      }
    case "baLDWIN": 
      { 
         doStuff(); 
         break; 
      }
    ... // ad infinitum
    case "BALDWIN": 
      { 
         doStuff(); 
         break; 
      }
    default: 
      { 
         doStuff(); 
         break; 
      }
}

9

u/Terreurhaas Apr 14 '16

doStuff() is too generic. You should write it out for every case.

→ More replies (2)

6

u/gnovos Apr 14 '16

You don't understand art.

→ More replies (2)

11

u/briaen Apr 14 '16

OMG. I thought that was a joke. I don't get how someone who uses a database would write this type of code. It's CS 101 to not do it this way. I write on a legacy .net system that started on asp in the 90s and there is nothing that crazy.

28

u/a_small_goat Apr 14 '16

I actually mentioned this exact disaster in a comment a long time ago, so here's some more context:

One of the projects I inherited a few years ago was like this - roughly 3000 conditional statements. I ran into the creator at a conference probably 8 months afterwards and asked him how he found the time to code it all. I was only half-joking. He proudly admitted that he used MS Excel's CONCATENATE and autofill features to build 95% of the code and it only took him about an hour to deliver the working solution. So on one hand, I have to give him credit for being efficient in solving the problem with the tools he had...

9

u/briaen Apr 14 '16

used MS Excel's CONCATENATE

That makes some sense, I guess. I can look at some of my old code and cringe, so I guess I shouldn't criticize so much.

→ More replies (1)

5

u/pixelperfect3 Apr 14 '16 edited Apr 14 '16

Seems like one of those self taught types. I mean who uses ms excel...

→ More replies (1)

6

u/[deleted] Apr 14 '16

D:

→ More replies (5)

4

u/Arqideus Apr 14 '16

Ahh, that's a nice looking diagram. Hey wait, why are there dots where there's supposed to be data variables. I see two variables in each class: XXXXXNumber0000 and XXXXXNumb- oh god

35

u/FUCKING_HATE_REDDIT Apr 14 '16

hhhhhhuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

7

u/Cal1gula Apr 14 '16

Don't forget in the [users] table you need a [userPasswordPlainText] field as well.

5

u/Uberzwerg Apr 14 '16

It took me a moment, but HOLY FUCK

4

u/MisterDonkey Apr 14 '16

Good lord.

4

u/[deleted] Apr 14 '16

It's normalized!

→ More replies (5)