3 ms·
I'm not sure if the argument that OOP is pleasant so long as you avoid any OOP is a very sturdy one.
by Etheryte 1y ago
I'm not sure if the argument that OOP is pleasant so long as you avoid any OOP is a very sturdy one.
- _old_dude_ 1y agoOOP is great for libraries but leads to overly complex codes for applications. For a long time, Java was like, every classes is a library, i do not think it's a failure of OOP, it's a failure of Java. But I'm optimistic, I choose to see recent additions like records and pattern matching has a step in the right direction.
- turtles3 1y agoI'd say that the 'poor man's closures' aspect of OOP - that is, being able to package some context along with behaviour is the most useful part for day to day code. Only occasionally is inheritance of anything other than an interface valuable. Whether or not this is an endorsement of OOP or a criticism is open to interpretation.
- SkiFire13 1y agoOOP is the combination of encapsulation, abstraction, inheritance, and polymorphism. Ignoring inheritance does not mean avoiding OOP altogether.
- Someone 1y agoAlso note that the OP said “avoid extending classes”, but didn’t say “avoid implementing interfaces”, so they don’t disallow inheritance in a wide sense of the word. I think “avoid extending classes” is there because it is as good as impossible to design classes that can be extended easily in ways you do not foresee, and if you do foresee how your classes could be extended, it often is easier for your users if you made your classes more flexible, to start with.
- hajile 1y agoYou can get Encapsulation, abstraction, and polymorphism any number of other ways. Inheritance is the only defining property of OOP. If you removed all the stuff related to inheritance and trying to fix the leaky abstraction that is objects, the language would be a fraction of the size (compare with Go or StandardML for how small a language without inheritance can be).
- zelphirkalt 1y agoAnd as for inheritance: Composition over inheritance. So .... just don't do OOP, I guess?