3 ms·
People love to hate on inheritance and suggest that there are no cases where its use is warranted. But inheritance absolutely is used, and successfully, in many
by adrianmsmith 6y ago
People love to hate on inheritance and suggest that there are no cases where its use is warranted. But inheritance absolutely is used, and successfully, in many frameworks. For example GUI frameworks [1] [2] or server-side web frameworks [3]. People have been writing code in frameworks like this for ages and as far as I can see they worked well.
Including key use cases such as being able to use the provided components "out of the box" and also being able to customize them, i.e. "like this component, but with these differences".
[1] https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Button.html https://docs.oracle.com/javase/8/javafx/api/javafx/scene/con...
[2] https://developer.apple.com/documentation/appkit/nsbutton https://developer.apple.com/documentation/appkit/nsbutton
[3] https://ci.apache.org/projects/wicket/apidocs/org/apache/wicket/markup/html/form/Button.html https://ci.apache.org/projects/wicket/apidocs/org/apache/wic...
- arcticbull 6y agoJust because there's examples of successful usages doesn't necessarily mean that it's "good" or even a model for how we do things moving forward. Picking that specific example [NS|UI]Button, they're dreadful to work with. Honestly. Customizing them is difficult to impossible. It's often easier to just compose them into a different container because the extension points couldn't possibly be designed in a way that gives you all the flexibility you need. Yes, it works, and yes, there are great systems built with OOP patterns. The same can be said of C++. That doesn't mean they're good, or we should choose it as our tool moving forward.
- hombre_fatal 6y agoNot very compelling. Your point that people have been able to leverage something to build something applies to everything. Doesn't mean it's good nor that there isn't a whole rest-of-the-continuum of things that are better. Look at all the things humans built before 21st-century tooling. So what? GUI frameworks like NS/UIKit and CoreData aren't good. They're quite bad, actually. That's why we are moving on. It's just that the pendulum has swing so far away from OOP in our zeitgeist for enough time that the new audience is feeding a new wave of "X is actually good!" We can see the same with PHP-related HN submissions right now.