Ep17 - Why Inheritance is bad? OOP Composition vs Inheritance

preview_player
Показать описание

Sometimes inheritance is considered as a bad practice. Let's look at why and how could we solve this.

------------

Source code for this lesson:

** Affiliated links
Use the legendary Git GUI for FREE! You are seriously missing out if you are not using it.

Beautiful designs created instantly to wow your social networks!

A simple and scalable cloud hosting platform for all developer needs.

Outro Music:
Рекомендации по теме
Комментарии
Автор

Thanks for clearly explaining the disadvantage of inheritance!

detaaditya
Автор

Hey there! First of all, thank you so much for the video. I just wanted to ask what the (option = {}) and ...option, are for. I didn't really quite understand. Thanks!

__jake.m
Автор

There are design patterns to prevent this kind of thing. Simplifying it to inheritance vs composition is a bit reductive, although I completely agree that composition is usually more powerful. You could have easily solved this problem with interfaces as well though.

Kyle-kefx
Автор

Inheritance could've achieved that. That example of inheritance was deliberately wronged.

Inheritance could've achieved same thing with same constructs (Runnable, Swimmable) where these would be Virtual classes.

avinashthakur