#but the real world is not like that.

1 messages · Page 1 of 1 (latest)

warped sun
#

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.

last heron
#

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

warped sun
warped sun
last heron
#

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

warped sun
#

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).

last heron
warped sun
#

If you are doing automation, by example, doing OOP is actual kinda dumb in multiple case.

last heron
#

some game dev but in typescript

warped sun
last heron
#

like Ill make web driver bots with python

#

or a web app for writing logic proofs in

#

or some physics simulations

#

(on the web)

warped sun
last heron
#

yeah

#

most ts are just react web devs

warped sun
#

So yeah, if you are talking about OOP to those people they might push back.

last heron
#

and many web devs cant even tell you what an abstract class is lol

#

with confidence

warped sun