Skip to content
0:00 / 0:00

#inheritance#composition#oop

The Flaws of Inheritance

CodeAesthetic

438K subscribers • 3 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

1.3M views3 years ago2 recommendations

Software designDesign patternsSoftware architectureObject-oriented design

CodeAesthetic explains the tradeoffs between inheritance and composition in object-oriented programming.

Let's discuss the tradeoffs between Inheritance and Composition Access to code examples, discord, song names and more at patreon.com/codeaesthetic Introduction Inheritance Composition Abstracting with Inheritance Abstracting with Interfaces When to use Inheritance

Why it's here

2 people recommend this

What people say. Recommended as a clear explanation of why composition is often preferred over inheritance.

u/DaSchTourin r/typescript • Recommends

On “Using rich classes when building with frameworks”

I found the Visitor Pattern very helpful for this. You can leave data/state objects untouched and have the logic independent of the data. One benefit is also that you don’t have such a tight coupling between the data and the functionality. So you can also use one visitor for different data objects. On the other hand always remember to use composition over inheritance

u/justADeniin r/compsci • Recommends

On “Abstract Data Types in Java”

This is typical inheritance vs composition problem. In some cases, it doesn't matter which one you choose. In more complex cases, composition (interfaces) is better. Here is an interesting video from CodeAesthetic on this subject: link to this video