3 ms·
Like I already said, inheritance is an advanced programming language feature that is easily misused. To give a specific example out of context would just leave
by gengstrand 5y ago
Like I already said, inheritance is an advanced programming language feature that is easily misused. To give a specific example out of context would just leave you open to inventing context that would yield inheritance as an improper choice.
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.
- sagichmal 5y ago> 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.