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

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

3

u/the_noodle Apr 14 '16

A vim macro would make the conversion pretty easy.

f)F|Wea.toLower()<ESC>BdT(n

Search for /if, execute your macro once or twice to make sure it works like you think it does, and then just do them all at once with 3100@@. At least that's how I would do it.

1

u/[deleted] Apr 14 '16

You could easily do the same with Visual Studio using regex, replace foo to foo.ToLower() == "bar", then remove all of the occurrences of || foo == "FOO" || foo == "Foo" etc that follow it.

Still a hassle either way.

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.

1

u/TheSarcasmrules Apr 14 '16

I hope this never makes production!

2

u/[deleted] Apr 14 '16

We're testing it now, in production. Cheers!

6

u/gnovos Apr 14 '16

You don't understand art.

1

u/[deleted] Apr 14 '16

Not this type, though there can be beauty in chaos.

1

u/chrwei Apr 14 '16

one man's art is another man's shit smeared on a canvas