4 ms·
That’s happening with OOP. I remember I picked up this codebase circa 2008 and this guy who worked on it before was learning OOP. Every little thing was a clas
by grugagag 4y ago
That’s happening with OOP. I remember I picked up this codebase circa 2008 and this guy who worked on it before was learning OOP. Every little thing was a class, lots of pointless inheritance everywhere and nothing made much sense at all. Luckily the project was easy to scrap and rebuild.
- ilyt 4y agoI still think it's funny that half of the OOP tutorials are "imagine that hierarchy of real things unrelated to anything programming and pretend for a second what we make is sensible" instead of giving actual real useful use cases.
- grugagag 4y agoOnce a bad idea is introduced it’s hard to stop. Tutorials are copying from eachother and more and more are ingraining those ideas.
- pull_my_finger 4y agoI think that's the idea though. It's for domain modeling. What's wrong with OOP as an abstraction over your FP foundation?
- rcme 4y agoGenerally, OOP makes it very difficult to reason about what is happening. Sub-classes can override methods in subtly different ways, internal state can be updated, super classes require changes to implement certain things in sub-classes, etc. Composition over inheritance has been much more robust in my experience.
- pull_my_finger 4y agoSounds like most of your complaints are about things that even OOP advocates recommend against these days. Multiple inheritance is rare in practice, and even rare in language support. Some newer OO languages, like Pony for example, don't support sub-classing at all and instead uses interfaces to represent that sort of information.
- ilyt 4y ago..the idea your code contains apples and oranges? I'm talking about the tutorials that wish the examples out of some random everyday items instead of having example app that uses the inheritance in useful way on code that someone with actual problem might write.
- rcme 4y agoYes, 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.