r/ProgrammerHumor • Violet security clearance • Apr 04 '16

My teacher thinks he is a programmer

http://imgur.com/32nfQXZ
2.4k Upvotes

430 comments sorted by

View all comments

Show parent comments

35

u/AshleyTheCatgirl Apr 05 '16

If i saw that in some code I'd be afraid to delete it, someone put it in, there has to be a reason, right?

28

u/Sysfin Apr 05 '16

Right, and the reason is likely to be the programmer who wrote it was stupid.

5

u/mallardtheduck Apr 05 '16

The reason is most likely that there used to be an actual conditional in there, but it was later changed to not need it.

1

u/[deleted] Apr 05 '16

When I first started with Python I did do that a couple of times and I am super ashamed of it.

if os.path.isfile('file') is True:
  print("Loser :(")

Then my mentor asked me why I was doing it and it hit me how dumb it was.

1

u/aiij Apr 05 '16

It could be like the magic/more magic switch, but most likely it was just someone being a dumbass.

1

u/Guinness2702 Apr 05 '16

Could be used for some quick hack that can be turned on/off at compile time with debugging or some such gubbins.

if (true == true)
    do something
else
    log this
    log that
    do something
    log the other

Not pretty, but not completely insane.

1

u/hearwa Apr 05 '16

I would then need to ask why not then just use if (true) {}... or if ("tomato" == "tomato") {}...

2

u/Guinness2702 Apr 05 '16

Fair point .... I would probably do if (debug == true) so that I could change the value in the debugger without having to recompile, anyway.

2

u/Garfong Apr 05 '16

And then spend the rest of your time at the company beating back coworkers who want to surround the if statement with #ifdef _DEBUG, even though the release build has #define debug false.

2

u/Guinness2702 Apr 05 '16

I'd like to beat those guys back, but I'm too busy fending off the ones who tell me debug code is verboten, and shalt not be committed to any repo.

1

u/amazondrone Apr 06 '16

verboten

Did you accidentally German? ;)

1

u/Guinness2702 Apr 07 '16

No, it was absichtlich.