Re:Show HN: We wrote a book about building business applicat...
by sagichmal on Thursday May 13, 2021 @09:16PM
(#27149514)
> inheritance is an advanced programming language feature
It really isn't.
> that is easily misused.
If a tool is misused frequently enough, it really isn't the fault of the users.
There is plenty of advice online already about how to use inheritance properly. In general, inheritance should be used to signal taxonomy. It should not be used to DRY unless there are good extenuating reasons behind that. There are lots of frameworks that require the use of inheritance which is somewhat unfortunate. You are most probably okay until you find yourself starting to form deep inheritance hierarchies. If you do have deep taxonomies, then consider modeling that in data (e.g. widgetType or widgetParent) instead of using inheritance. The decorator pattern is also used a lot when inheritance gets out of hand.