3 ms·
Why People Misuse Inheritance
- magicalhippo 4y agoI expect that in a language that has such blessed, boilerplate-free delegation tools, inheritance will be less overused. Delphi has support for delegation[1], but sadly not partial delegation. However it doesn't seem like a big thing, compiler-wise, in a language like Delphi or C# to support partial delegation. You could then have one line saying that by default all calls are delegated to a given instance, a member/field or similar, and the compiler could then just automatically generate the forwarding calls for the methods you don't implement explicitly. But wait... this is starting to smell a lot like inheritance! There the compiler automatically handles the delegation of the calls to the base class unless you override. Of course there's still a big difference, in that typically inheritance is bidirectional while delegation is unidirectional. [1]: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_Implements_for_Delegation https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_Im...