Hacker News new | past | comments | ask | show | jobs | submit login

As an example of taking this to an extreme, I was at a coderetreat where we had to implement Conway's Game of Life without any if statements (or similar, such as switches) -- we had to use polymorphism instead. The result was that my partner and I ended up reimplementing a subset of the natural numbers as distinct classes.

http://mike.zwobble.org/2012/12/polymorphism-and-reimplement...

I'm definitely not advocating this as good programming practice, but the point is that if you're used to always using if statements, then it's hard to learn alternatives. By forcing yourself to use the unfamiliar, you might find some situations where polymorphism is better suited to the problem, whereas you would have previously defaulted to using ifs.

(barrkel has already left an excellent comment on when the two styles are useful, so I won't repeat it:

http://news.ycombinator.com/item?id=4977487)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: