Earlier quoted context omitted.
> For me the main point is (runtime) polymorphism. E.g. you have a function that takes a general type, and you can pass multiple specific types and it will do the right thing. The runtime part is what I dislike. If I have a fruit which is an apple or a banana, I can't pass that to a method expecting an apple or banana. It can only be passed as a fruit. > And if you want to avoid huge if-else statements, you should pu…
> I prefer to have all the type-checking code inside the TypeCheck module There are ways to have your cake and eat it too, here, at least in some languages and patterns. For example, in Go you could define "CheckType" as part of the interface contract, but group all implementors' versions of that method in the same file, calling out to nearby private helper functions for common logic. Ruby's open classes and Rust's m…
It's less "this is not OO" and more this is not inheritance, which is why a lot of people are saying you can find more elegant solutions (like this) rather than use inheritance for no clear benefit.