4 ms·
Would you be able to share an example of an abstraction you wanted to create in enterprise computing where lack of inheritance stymied you?
by hannofcart 5y ago
Would you be able to share an example of an abstraction you wanted to create in enterprise computing where lack of inheritance stymied you?
- segmondy 5y agoI was going along with the comment till they mentioned inheritance too. I hope they can share such an example.
- gengstrand 5y agoLike 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.