I’ve never once used that knowledge professionally to any sort of success. The complexity of polymorphism always ended up biting us (any company/org I’ve worked at) in the ass when things eventually grew way too far apart than what was originally envisioned when the polymorphism made sense.
Kinda hilarious that they are still teaching it with those useless examples though. You’d have thought they could come up with something better by now. I mean, I get why you’d chose something obvious, but in my experience CS students seem to understand polymorphism perfectly well without making a duck quack and a dog go woof.
But what do I know, I can’t even make it work.
Even 1 + 1 is polymorphic, ie., "1" + "1" selects for a different behaviour.
Method overriding may rely on inheritance, and the problem is usually the inheritance not the polymorphism.
I still object on the subtype grounds though -- because the issue is not the polymorphism (that is useful and usually a good idea). It's the inheritance relation, which is not the subtype relation -- eg., you can do subtype polymorphism with just implementing interfaces and there shouldn't be any problems.
This comment is actually expressing issues which have arisen because of inheritance and confusing it with polymorphism.
> The problem comes when you want to add continually new methods all the time
This is not a real problem! Violating encapsulation to avoid dealing with the occasional merge conflict is probably the worst use of pattern matching I've ever seen. The tug-of-war between OO and FP is greatly exaggerated.