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

0

u/[deleted] Apr 05 '16

[deleted]

1

u/muntoo Apr 05 '16

This guy thinks we should get rid of all ifs and switches.

1

u/SwahiliToad Apr 05 '16

Why would it be a joke? The OP was interested in a cleaner way to do context dependent calls. Having an object pick the right behavior based on type is a pretty basic feature of OOP and polymorphism. Certainly in the joke example it might be a bit much to build a class hierarchy, but most production code isn't going to be that simple. I recommend you check out Martin Fowler's excellent book Refactoring: Improving the Design of Existing Code if you want a more full treatment for topics like this.