3 ms·
What is the practical difference between inheritance, and a trait or interface with a default implementation? It seems like both risk the addAll() bug.
by ridiculous_fish 5y ago
What is the practical difference between inheritance, and a trait or interface with a default implementation? It seems like both risk the addAll() bug.
- rackjack 5y agoMultiple inheritance is basically strictly more powerful than either traits or interfaces with default implementations. I don't think traits or interfaces with default implementations prevent the bug, as I can imagine a Rust implementation that would do something similar.
- magicalhippo 5y agoNot all languages allow for an interface to have a default implementation though. Delphi for example does not. This leads the programmer towards composition and delegation. To aid with this, Delphi even has some sugar for delegation[1]. [1]: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Using_Implements_for_Delegation https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Usin...