SamuZai
codeaesthetic
codeaesthetic

patreon


Upcoming video

Next up is the classic "Composition over Inheritance". What are your opinions on the subject?

Comments

I have very rarely seen inheritance be useful in my career. It is often used as a way to share behavior rather than display an is-a relationship. This often creates more complexity and is typical used as a poor abstraction. Composition usually solves this problem by forcing engineers to think of better abstractions. An additional win is that composition makes testing significantly easier. One thing to be careful of with composition is abstracting to early creating a ton of small utility classes rather than think about good abstractions.

Kendall Morgan

learning more about it, I think it makes sense to use inheritance for attributes since that's basically the definition of an entity but for the actions of an entity, composition totally makes sense, though I'm unclear how that works in practice

JeremyJaydan

honestly I'm not sure, I feel like inheritance makes sense intuitively from a linguistics view of hypernyms and hyponyms but composition.. what are the rules around that? Is it the same? I don't think I've used composition enough in the way of using it over inheritance to understand the benefits

JeremyJaydan


More Creators