6 ms·
Yes, it's actually a huge red flag that you never see useful examples of inheritance.
by rcme 4y ago
Yes, it's actually a huge red flag that you never see useful examples of inheritance.
- 6510 4y agoI would like to see one. Ideally one that has the functional programmer rewrite things. I don't have any bias besides being completely ignorant about classes. The tutorials do talk to me about cars being a sub class of vehicles and the prevention of rewriting things. My mind goes like: "Hierarchies? seems bad?: You have buildings and vehicles with cars belonging to vehicles and habitats belonging to buildings. Where put the RV? Are writers children of nationality or is nationality a child of writer?" iow the example is probably to unrelated to programming to be a sensible one.
- charcircuit 4y ago>Where put the RV? Both. You can have a RVVehicle class and a RVHabitat class. Nothing is forcing you to have 1 class. If it makes more sense to be just one class you can also make it a subclass of 2 classes. >Are writers children of nationality or is nationality a child of writer? Nationality would be a child of writer.
- bazoom42 4y ago> Are writers children of nationality or is nationality a child of writer? Wouldnt that be a has-a relationship? Represented by composition rater than inheritance.
- bazoom42 4y agoThe useful example is UI control hierachies. GUI’s was one of the early sucesses of OOP. Those “Dog descend from Animal and has a bark() method” just confuses the issue. Inplementation inheritance is a useful tool when you need it, but it’s not that central to OOP.
- xialvjun 4y agoOOP is successful in GUI app is because states are at everywhere in GUI app. Many other apps don't have many states to manage, OOP is bad for them.