Re:Design Patterns – A comprehensible guide
by js8 on Friday February 17, 2017 @01:22AM
(#13666330)
You don't need overriding, in fact you should avoid it. All five functions are already valid operations on the type class (the data you have). If you want to add an operator, then you define another function (with another name) and call it. If the existing modules need to call that operator instead, change them to be explicit about what you're doing.
This is where OOP gets it wrong, because this situation leads to logical contradictions (breaking the type system), in particular, breaking of the LSP.
This is where OOP gets it wrong, because this situation leads to logical contradictions (breaking the type system), in particular, breaking of the LSP.