#but the real world is not like that.
1 messages · Page 1 of 1 (latest)
Composition and inheritance are both useful tool. Multi inheritance and deep layered inheritance are not.
- Increase the risk of failure as you stated
inheritance takes a lot more planning and philosophizing to do safely
- Reduce the flexibility as you stated
composition patterns have the advantage of letting you start with little abstraction architecting, and still retain flexibility, since if you get it conceptually wrong at first it's easy to fix (or ignore)
- Require more expertise/experience to work with as you stated.
And you usually only need to do a lot of planning when you're still new to OOP. once you get good at it, you can go really fast and naturally
- Require more discipline as you stated
most programmers do not want to do this; they dont want to start 3 levels above in abstraction land before they even start talking about their app
- It increase the complexity
Deep layered inheritance - You have to deal with long abstraction chain (instead of having all feature on the same level; Which class you would need to inherit if you only want this specific feature)
or
Multi inheritance - exponential ambiguity (As you increase the amount of class you inherit, you increase the chance that you have an ambiguity exponentially).
In the other hand, it is more natural to say that a bird is an animal and that it is a flying animal then to say it is an animal and it has the capacity to fly. However, is it really a good thing to enable someone to modelized something like that ? We all know that we are going to either have a non flying animal or an object that is not an animal but is flying at some point.
I acknowledge the difficulties inheritance imposes navigating if you want to do it well, but I think the naturalness point and the lack of needing to reimplement wrapper/bridge delegate calls is often worth it
the points about safety and discipline/complexity are not a concern to me since I am really good at oop
i do it all day every day so i dont have the same problems most people talk about. I have internalized it
but they are a concern for other developers yes
but in my game engine, I did opt for a pure ECS approach
because I can just see how much nicer composition is here
but even with that, I still combine it with inheritance
like I have inheritance hierarchies of Components
so Entities are composed of Components, and Component is an abstract base class with many subtype of components
no inheritance and no composition both seem like equally bizarre mindsets to code in
gotta have both in certain cases
Composition and ECS is totally different
I still believe that same if you pretty decent at something, you should always consider your teammate. They might not be as good as you are which would cause a lot of issue down the road.
yeah sure, I am pushing back against all the hatred OOP / inheritance gets
i think its primarily a skill issue
and thats fine that beginner devs struggle with it
but they misinterpret that and think its oops fault
Inheritance and OOP does not get that much hates. Only a small amount of people hate it.
Multi inheritance and Deep Inheritance is another thing.
At no point did I ever say that inheritance is bad, simply that you should always prefer composition over it (It is a generalization).
might just be the communities I am in. I rarely ever find someone else who likes it
What exactly are you doing as a job ? Is it Video Game ? Because in some scenario, OOP is not necessary a gain.
If you are doing automation, by example, doing OOP is actual kinda dumb in multiple case.
python / typescript stuff. general apps
some game dev but in typescript
What are you using it for ?
just all sorts of stuff. (im a hobbyest, dont have a job in the industry)
like Ill make web driver bots with python
or a web app for writing logic proofs in
or some physics simulations
(on the web)
Typescript is not necessary used for game dev. I would not be surprise that most people that use it have other reality which makes OOP kinda to much.
So yeah, if you are talking about OOP to those people they might push back.
Frontend developer are not really creating any structure. They are pretty much just configuring classes and defining procedure.