The Only Time You Should Use Polymorphism

preview_player
Показать описание
The only time you should use subtype polymorphism is when you have behavioural variation in the subtypes. I teach two university courses on object oriented programming and I see this problem a lot. Let me explain.

💚 BUY MY BOOK:

RECOMMENDED READING:

Read my FREE book on Object Oriented Programming:

Watch next:

CONTENTS:
00:00 Thesis
01:16 Example 1
03:28 Example 2
06:25 Example 3
13:26 Summary
Рекомендации по теме
Комментарии
Автор

He randomly came back after three years! Tak! Good to see you again.

AdanSolas
Автор

I like to think, that you got so annoyed by someone at work using subtype polymorphism the wrong way, that it brought you back here ;)

Pawemie
Автор

literally just watched your design patten playlist, thinking why hasn't he posted for 3 years. perfect timing

EricFreedmanMusic
Автор

Man, your notification popping up is the best thing happened in months❤, please don't disappear again :)

arminium
Автор

I've never been more engaged with software engineering YouTube content. Your presentation skills are excellent.

culturemanoftheages
Автор

I would add a point that "variations in behavior" can also come from _outside_ the class - a class can just be a data type, without being responsible for all the ways the data will be used. Imagine an Attack subtype, EnergyAttack, which has an additional property EnergyType. Now Scratch is a base Attack instance, and Thunderbolt is an EnergyAttack (with EnergyType = Lightning). Looking at just the class definitions, you could say this is a data-only variation, but it makes sense because the change is in the data structure (an additional property), not just values. These subclasses may or may not implement variations in behavior themselves, but _allow for_ external variations by being different types: We may have many general functions that work with the Attack type, as well as some functions that accept EnergyAttack specifically and work with the EnergyType property.

TazG
Автор

Welcome back! Got a huge amount of value out of this channel in my early days of becoming a dev

williamcory
Автор

I came to the comments section to share my excitement about your return.
But, wow, I didn't expect there to be so many of us!

sam_musey
Автор

Suddenly you appeared out of thin air, please be consistent. Love your content.

dhruvachandra
Автор

I didnt even fully read the title, I just saw the thumbnail and clicked. Welcome back good sir.

davidntumba
Автор

Oh my god. I used to watch your videos when I started learning programming in 2021. Right now, I have an interview with Google scheduled next week. You don't know how happy I am to see you back. Thanks for coming and welcome back :)

mohamedsayed
Автор

Have been watching your Design Patterns series and the code walks videos and was always thinking if I ever wanted to have a youtube channel it would have been of this style. If only he was back. Wish granted, welcome back, so happy to see notifications from you! :DDDD

andreaskonomis
Автор

Awesome to see you back Chris! I’ve learned a lot from your videos, and have always enjoyed hearing your perspective on things. 😎👍

CarlRoa
Автор

Your teaching is the greatest and simpler....❤

kiranmahajan
Автор

I didn't learn anything, but the way you described the information in the video *clarified* what I'd already known -if that makes sense.
You are excellent at explaining things in very clear terms, and I appreciate that. Subbed.

drewbruggman
Автор

I watch your videos and you are the first teacher whoes course i can buy without thinking about money.

Flutterdev
Автор

Once again, you enlightened me about something that might seen implicitly known and simple but in reality a truly good software engineer needs to be absolute aware of.

EmpySoul
Автор

Your knowledge is actually so precious. I love the fact that you just use concepts with whiteboard. Thank You for coming back to us, You can make a lot of us promote with your videos!

arteqppp
Автор

Word to mother....ur design patterns videos helped me nail an interview in 2017 🤣🤣🤣. Now I'm a Lead software engineer. Thanks

securethebag
Автор

I started watching him on thursday, fell in love in his way of teaching, and was thrilled when saw that last video was posted 3 years ago. And now he appears out of nowhere 😂 If you were giving lectures on my Uni, i wouldnt miss a single one

Ruzi