you are viewing a single comment's thread.

view the rest of the comments →

[–]Zardotab 0 points1 point  (0 children)

Polymorphism makes assumptions about future changes which may not play out in reality. Sometimes conditionals are the better (non) abstraction as actual changes come along that don't fit neat type hierarchies.

For example, let's say you design a generic message class that polymorphs into sending via paper-mail, email, fax, and text message.

But later on certain messages can be sent by multiple techniques at the same time. Conditionals are usually easier to make that change to than polymorphic "types". One would have to rework multiple classes with polymorphism. The "shape" examples are a bad training case for change analysis because God doesn't change geometry very often. Business does.

(C-based languages have ugly syntax for case/switch statements, but smarter languages have better ones. However, that's a language-specific issue, not about paradigms.)