@@sabrinakingsley798 Objectification involves treating the person purely as an object, which is not what I did. I wrote that he was a great programmer and a fantastic teacher. He also happens to be very handsome, which I mentioned. Had I only written something like "you're hot," I'd understand your comment, but it's not what was written.
Kyle, your approach to explaining these abstract, seemingly obscure principles and concepts with simple examples, is brilliant. So instead of approaching dry and abstract concepts from the top down with professorial lectures of principles that need to be understood, your bottom up approach with spot-on examples illuminate the subject matter. I have noticed how your subscriber base has been deservedly growing, and it is because of your clarity in presenting these topics and the relatively short videos that make it digestible. I wish you much continued success and look forward to your new videos. Best always.
This is an interview question I used to ask devs.. Btw, between square inherits rect or rect inherits square, always inherit rect from square, as you are adding a paramater, a second size dimension. Square has sideLength. Rectangle has a second sid legnth. Things get a lot cleaner following that.
Thanks a bunch. Found your video while searching about "Why is it not allowed to narrow down scope of a method while overriding?" and also why the developers choose to do so. It makes sense now. Thanks for making these topics so easy to understand.
Okay... This is probably the first time i understood liskov. Thanks a lot man and yea i think you should make videos on composition and aggregation too... Overall your content for solid is pretty solid 🎉👌
Sounds like polymorphism to me. I've used polymorism twice to very good avail. Once in an undo/redo (stack based) system and once in a linked list of tokens. And all I can say is Thank God for it. And one thing I love about it is how it allows for future expansion. If I should add new token types or undo/redo types on the future, no sweat. I don't have to change a thing in either my containers or my base classes. I could even distribute the code as a library and never worry about users needing to change the base code.
I used to think I write good programs, but after learning SOLID principles I realized why I am getting all those rejections! Thank you Kyle for such awesome content. chhers!
You know, I never learnt anymuch from anyother channels.. Just awesome , u r making programming fun and interesting .. But one drawback, after watching your contents, I can not spend my time in other channels
I’m just starting out on programming and these design videos are fantastic for understanding the principles easily from the beginning of my journey. YES for Composition please :-)
Wow amazing explanation, this is the first time I've been able to understand this principle. Although I should add that nowadays in python classes can inherit from multiple classes so that sort of sidesteps that issue
I kind of feel the bird issue is actually an interface issue. Like, it should not ask duck.fly(), but rather duck.go(). And penguin.go(). Now, whether the bird flies or swims is the bird's class concern. Client code just needs a fixed, reliable interface. And that's what Liskov Substitution Principle is about.
I totally agree. this will be fixed with an interface instead of creating 2 separate super class of different birds(e.g flyingBird and swimming bird).. it just like all birds can move but move differently is what the essence of liskov substitution principle is about
love you videos my man! I started a course and i'm already way ahead of the knowledge provided so using your vids to keep that momentum. I want some WDS merch! I'm thinking beanies, bum bags and night pants!
Implementing the Liskov principle in JS is a challenge compared to C# mainly because JS does not have the concept of interfaces. So implementing this is more of a personal discipline. I'm not against JS. I look at it as a wild language. Still this is a great explanation on how to clean up code!
I never heard of Liskov before, but this makes so much sense! Also Kyle, could you please actually make a video on composition?? A few weeks ago I was trying to write a small game engine in JavaScript, and I ran into the exact problem you were describing when I tried to make a class for objects that could be movable, drawable to the screen, and have behavior states. I eventually ended up using composition similar to how unity game objects work, but I’m not sure if I still fully grasp the concept. Thank you!
Thanks Sir, for everything you putting efforts and what you are doing for us! . And I challenge you to make a tutorial on any board game, like chess, checkers, carrom etc. Anything you can make with js. But must be a board game.
The second part is a way to understand this simply, the first part is a way to understand that sometimes, your code might not pass the liskov principle and you might not see it that simply like in the second part.
I'm from UA...looking for several hours articles which can explain me this moskovian guy principle) thank you - I got it everything) even with my low english level!)
Thinking as you’re talking. I wonder if the issue is with trying to inherit actions, which can change. If the birds inherited Wings (the object) instead of Flying (the action), then, Pigeon Wings can fly. Penguin wings can swim. And Duck wings can fly. Ducks swim with their feet. So the feet objects for Ducks can walk and/or swim. Inheritance can save a lot of time. So inheriting correctly is probably the right answer to the problem.
@WebDevSimplified I may be wrong but I find the explanation little bit wrong. Taking the bird example, Liskov Substitution Principle (LSV) is not violated if say Penguin and Duck's fly() behave differently, meaning duck's instance fly() will say "I can fly" and penguin's instance fly() will error out saying "Cannot fly". This is what Polymorphism is, different class instances behaving differently on calling the same function. LSV states that "if a function takes an instance of a class, the same function should be able to take an instance of derived class from that class and the functionality of that function should not break". LSV would be violated if say Penguin class implements a function called penguinFly() that will error out saying "Cannot fly" but does not implement fly(). So now the client, meaning the user of the Penguin instance has to know that it has to call penguinFly() to get correct functionality because if we call penguin's instance fly(), it will say "I can fly" which is not correct behavior and now LSV is violated.
I think one problem with the polymorphism is that the type could not be inferred dynamically. If we declare the object like Rect rec = new Square() Then the rec can only be recognized as Square in the lifetime of the object. In that case it is fixed, which is different like real world (Start shape is square, but as we elongate the side it could be transformed to Rect).
8:16 Is this a problem that can be fixed using interfaces? Like, you could create a base class of bird, and have child classes inherit from interfaces as needed? I know JavaScript doesn't have interfaces, but I am learning C# and it does have interfaces. Interfaces imo should theoretically solve this issue. Like you have an interface for a flying bird and one for a swimming bird. A base class called bird, then penguin just takes the swimming bird interface, and duck takes the swimming bird and flying bird interface? Or would this still potentially be a violation of this principle? I'm trying to understand this principle and why it's useful, but doesn't it defeat the purpose of creating subclasses if their functionality has to be backwards compatible (for a lack of better terms)? Why would we ever create a subclass if it's just going to behave like the parent class anyway?
The first example don't make 100% sense to me. Of course the program will not output the same area, you changed the implementation used. But there was no problem calling setWidth or area (exception). Just as if you had an animal that could make a sound, if it's a dog it will bark, if it's a cat it will meow. Does that then break the liskov principle as well?
I agree with you @MrAzulay. I don't understand how the first example breaks the Liskov Principle. Of course if you change Rectangle by Square the calculation is different. But the code doesn't break or display wrong result. In fact it calculates the right result! Am I missing something here? @WebDevSimplified
Hey, Thanks for the video, Your examples and explanations are very precise and clear. Can I suggest you create a Udemy account for your courses? It would be easier to find and keep track of since a lot of people learn using that platform.
if a class can't inherit multiple concrete classes cant we use interfaces like in this case IflyingBird and IswimmingBird interfaces and the bird can implement both interfaces?
As requested here is the composition vs inheritance video: ua-cam.com/video/nnwD5Lwwqdo/v-deo.html
You should add this to the Design patterns playlist.
Thank you senpai
Yes to composition vs inheritance video!
Up
Double yes to composition vs inheritance
I didn’t realize you could be a great programmer, a fantastic teacher, AND a supermodel at the same time. Great video.
rofl true tho
Maybe don't objectify the guy.
@@sabrinakingsley798 Jeez, here come the witch burners lol excuse us while we all go poke out our eyes to appease your social sensibilities
@@sabrinakingsley798 Objectification involves treating the person purely as an object, which is not what I did.
I wrote that he was a great programmer and a fantastic teacher. He also happens to be very handsome, which I mentioned.
Had I only written something like "you're hot," I'd understand your comment, but it's not what was written.
@@fernandobalino9519 Yeah, your format was compliment, compliment, AND objectification.
Kyle, your approach to explaining these abstract, seemingly obscure principles and concepts with simple examples, is brilliant. So instead of approaching dry and abstract concepts from the top down with professorial lectures of principles that need to be understood, your bottom up approach with spot-on examples illuminate the subject matter. I have noticed how your subscriber base has been deservedly growing, and it is because of your clarity in presenting these topics and the relatively short videos that make it digestible. I wish you much continued success and look forward to your new videos. Best always.
The best content for SOLID on the Internet.
I've read the whole clean code book by Uncle Bob and still didn't understand these SOLID principles as much as until your 10 minute video. Thanks!
You are the dom perignon of online JS educators. Clear, concise and well structured! Thanks very much for your content 🙌🏻
This is an interview question I used to ask devs.. Btw, between square inherits rect or rect inherits square, always inherit rect from square, as you are adding a paramater, a second size dimension. Square has sideLength. Rectangle has a second sid legnth. Things get a lot cleaner following that.
You are such a great instructor ! Finally I understand all about SOLID in just couple of minutes.
Uauh. I've programmed since 2000s (vb6, turbo Pascal, etc) and I still enjoy each one of your videos! Good job!
Thumbs up!!!Waiting for composition
Thanks a bunch. Found your video while searching about "Why is it not allowed to narrow down scope of a method while overriding?" and also why the developers choose to do so.
It makes sense now. Thanks for making these topics so easy to understand.
These expalmes are everywhere, really programmers cannot find more intresting expalmes...
Finally a simple explanation of the solid principles....👍 for composition vs. Inheritance
I love these SOLID principles series, nicely done man!
Okay... This is probably the first time i understood liskov. Thanks a lot man and yea i think you should make videos on composition and aggregation too...
Overall your content for solid is pretty solid 🎉👌
Sounds like polymorphism to me. I've used polymorism twice to very good avail. Once in an undo/redo (stack based) system and once in a linked list of tokens. And all I can say is Thank God for it. And one thing I love about it is how it allows for future expansion. If I should add new token types or undo/redo types on the future, no sweat. I don't have to change a thing in either my containers or my base classes. I could even distribute the code as a library and never worry about users needing to change the base code.
Thank you for simplifying the Liskov principle for all of us with easy-to-comprehend examples. Keep up the good work!
Hands down best coding channel on UA-cam. Many thanks and keep em coming!
Thank you. As an amateur coder you have taught me tons. Thank you. Love your videos.
I had never understood the concepts of OOP in my school classes. Your explanations are very easy to understand!
And another very clear, clever and successful teaching video. Thank you!
Thank You So Much for this wonderful video........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
This was the most confusing one to me. I read several definitions before I finally decided to see what Kyle had to say about it. Good job!
Great series on the SOLID principles. Your content is fantastic.
I appreciate your channel. This is excellent content for people reviewing for job interviews.
That's one of the things I really like about PHP. You get interfaces and abstract classes and traits.
I used to think I write good programs, but after learning SOLID principles I realized why I am getting all those rejections! Thank you Kyle for such awesome content. chhers!
thanks a lot i have exams tomorow and you just saved my day with thoses clear explaination
Congrats on 100K!!!
and great explanation.
You know, I never learnt anymuch from anyother channels.. Just awesome , u r making programming fun and interesting .. But one drawback, after watching your contents, I can not spend my time in other channels
Excellent video. Concise and to the point. Very helpful.
The bird inheritance example was so cute. Your explanations are easy to follow. You are such a great teacher. 😁👍
A Solid Video Concept from THE MAN - " Kyle WDS " ! We love you man and happy holidays !
I’m just starting out on programming and these design videos are fantastic for understanding the principles easily from the beginning of my journey.
YES for Composition please :-)
Gratz for 100k
I love your videos so much Kyle! I had trouble understanding the SOLID Principles before, and your videos are so helpful for gaining understanding!
I'm glad I could help!
Yes for composition
Wow amazing explanation, this is the first time I've been able to understand this principle. Although I should add that nowadays in python classes can inherit from multiple classes so that sort of sidesteps that issue
In the modern world, we only need one guy to explain it better than our teachers to kick the exam in the nuts
I was craving for some good explanation about Liskov substitution. Thanks you very much!
PS: can't wait for I on SOLID.
Yes composition video please!!
Dude first, CONGRATS ON 100k subs!!!! You earned it man. Second, yes please do composition with JavaScript
So clear and easy to understand, thank you!
I kind of feel the bird issue is actually an interface issue.
Like, it should not ask duck.fly(), but rather duck.go(). And penguin.go().
Now, whether the bird flies or swims is the bird's class concern.
Client code just needs a fixed, reliable interface.
And that's what Liskov Substitution Principle is about.
I totally agree. this will be fixed with an interface instead of creating 2 separate super class of different birds(e.g flyingBird and swimming bird).. it just like all birds can move but move differently is what the essence of liskov substitution principle is about
love you videos my man! I started a course and i'm already way ahead of the knowledge provided so using your vids to keep that momentum. I want some WDS merch! I'm thinking beanies, bum bags and night pants!
Thank you man. Awesome class.
The bird method made LSP click; great example!!
Thanks Kyle 👏
Let's go for composition
this is off topic, but the lighting for your UA-cam setup is made the video quality way better!!! so nice going
Thank you!
Implementing the Liskov principle in JS is a challenge compared to C# mainly because JS does not have the concept of interfaces. So implementing this is more of a personal discipline. I'm not against JS. I look at it as a wild language. Still this is a great explanation on how to clean up code!
I never heard of Liskov before, but this makes so much sense! Also Kyle, could you please actually make a video on composition?? A few weeks ago I was trying to write a small game engine in JavaScript, and I ran into the exact problem you were describing when I tried to make a class for objects that could be movable, drawable to the screen, and have behavior states. I eventually ended up using composition similar to how unity game objects work, but I’m not sure if I still fully grasp the concept. Thank you!
Thanks Sir, for everything you putting efforts and what you are doing for us!
.
And I challenge you to make a tutorial on any board game, like chess, checkers, carrom etc. Anything you can make with js. But must be a board game.
Love your videos on SOLID and I want to see a video of compositiion vs inheritence video.
excellent explanation , thanks
The second part is a way to understand this simply, the first part is a way to understand that sometimes, your code might not pass the liskov principle and you might not see it that simply like in the second part.
More on composition please. Thanks man
+1 for composition over inheritance ...
Great explanation. Thank you, I'm satisfied.
Best tutorials...... I love ur all videos
Way better then my uni bro ty ♥
I'd love to sign up for Composition, too. And for more videos about the various birds in this world 🙂.
I'm from UA...looking for several hours articles which can explain me this moskovian guy principle) thank you - I got it everything) even with my low english level!)
i would like to hear from function compositions advantages! : )
Great video! :)
Thank you for the video.
Two thumbs up Kyle.
Yes, please do composition video.
Thinking as you’re talking. I wonder if the issue is with trying to inherit actions, which can change.
If the birds inherited Wings (the object) instead of Flying (the action), then, Pigeon Wings can fly. Penguin wings can swim. And Duck wings can fly.
Ducks swim with their feet. So the feet objects for Ducks can walk and/or swim.
Inheritance can save a lot of time. So inheriting correctly is probably the right answer to the problem.
Yes please share the video on composition
Great Video Fam.
love this series
@WebDevSimplified I may be wrong but I find the explanation little bit wrong. Taking the bird example, Liskov Substitution Principle (LSV) is not violated if say Penguin and Duck's fly() behave differently, meaning duck's instance fly() will say "I can fly" and penguin's instance fly() will error out saying "Cannot fly". This is what Polymorphism is, different class instances behaving differently on calling the same function. LSV states that "if a function takes an instance of a class, the same function should be able to take an instance of derived class from that class and the functionality of that function should not break". LSV would be violated if say Penguin class implements a function called penguinFly() that will error out saying "Cannot fly" but does not implement fly(). So now the client, meaning the user of the Penguin instance has to know that it has to call penguinFly() to get correct functionality because if we call penguin's instance fly(), it will say "I can fly" which is not correct behavior and now LSV is violated.
Woah. that just blew my mind
nice explanation. Good voice
Thank you for the great explanation. Are you planning to continue this series?
Or maybe doing series about design patterns like this?
I have a few videos in this series already uploaded and a few videos in a design patterns series as well that you can check out.
yes sir pls make video on composition
Liskov Substitution Principle can be called Base Class Segregation Principle as well. :D
Thank you brotha!
Your videos are awesome! would've loved it, if you could provide us with the src code as you did with the design patterns videos
I think one problem with the polymorphism is that the type could not be inferred dynamically.
If we declare the object like
Rect rec = new Square()
Then the rec can only be recognized as Square in the lifetime of the object. In that case it is fixed, which is different like real world (Start shape is square, but as we elongate the side it could be transformed to Rect).
Great video
you are cool bro. thx for all of your videos
For some reason, this reminded my of Strategy pattern.
Composition vs inheritance 👍
Please go ahead and make a video on composition and inheritance 👍🏻
GREAT VIDEOS!!!!!!!!!!!!!!
8:16 Is this a problem that can be fixed using interfaces? Like, you could create a base class of bird, and have child classes inherit from interfaces as needed? I know JavaScript doesn't have interfaces, but I am learning C# and it does have interfaces. Interfaces imo should theoretically solve this issue.
Like you have an interface for a flying bird and one for a swimming bird. A base class called bird, then penguin just takes the swimming bird interface, and duck takes the swimming bird and flying bird interface? Or would this still potentially be a violation of this principle?
I'm trying to understand this principle and why it's useful, but doesn't it defeat the purpose of creating subclasses if their functionality has to be backwards compatible (for a lack of better terms)? Why would we ever create a subclass if it's just going to behave like the parent class anyway?
thank you!!
Kindly make the video for oops concept in js
In other words, in React, child component's props should source entirely from parent component's props?
Great video as always! Yes please, I’d love to see a video about composition vs inheritance. Awesome content!!
You're the best.
The first example don't make 100% sense to me. Of course the program will not output the same area, you changed the implementation used. But there was no problem calling setWidth or area (exception). Just as if you had an animal that could make a sound, if it's a dog it will bark, if it's a cat it will meow. Does that then break the liskov principle as well?
I agree with you @MrAzulay. I don't understand how the first example breaks the Liskov Principle. Of course if you change Rectangle by Square the calculation is different. But the code doesn't break or display wrong result. In fact it calculates the right result! Am I missing something here? @WebDevSimplified
thank u very much !!!!!!
8:25 Unless you're using C++
Hey, Thanks for the video, Your examples and explanations are very precise and clear.
Can I suggest you create a Udemy account for your courses?
It would be easier to find and keep track of since a lot of people learn using that platform.
3:38 it should be a 6x6 not a 6x5. A square should have equal height and width. I don't see how the code was broken
You can implement more than one interface in java, that's what will solve the problem of swimming and flying bird.
if a class can't inherit multiple concrete classes cant we use interfaces like in this case IflyingBird and IswimmingBird interfaces and the bird can implement both interfaces?