TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why People Misuse Inheritance

2 pointsby memorableabout 2 years ago

1 comment

magicalhippoabout 2 years ago
<i>I expect that in a language that has such blessed, boilerplate-free delegation tools, inheritance will be less overused.</i><p>Delphi has support for delegation[1], but sadly not partial delegation.<p>However it doesn&#x27;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&#x2F;field or similar, and the compiler could then just automatically generate the forwarding calls for the methods you don&#x27;t implement explicitly.<p>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.<p>Of course there&#x27;s still a big difference, in that typically inheritance is bidirectional while delegation is unidirectional.<p>[1]: <a href="https:&#x2F;&#x2F;docwiki.embarcadero.com&#x2F;RADStudio&#x2F;Sydney&#x2F;en&#x2F;Using_Implements_for_Delegation" rel="nofollow">https:&#x2F;&#x2F;docwiki.embarcadero.com&#x2F;RADStudio&#x2F;Sydney&#x2F;en&#x2F;Using_Im...</a>