Liskov Substitution Principle Explained - SOLID Design Principles

Поділитися
Вставка
  • Опубліковано 13 гру 2024

КОМЕНТАРІ •

  • @WebDevSimplified
    @WebDevSimplified  5 років тому +70

    As requested here is the composition vs inheritance video: ua-cam.com/video/nnwD5Lwwqdo/v-deo.html

    • @NoahNobody
      @NoahNobody 3 роки тому

      You should add this to the Design patterns playlist.

    •  2 роки тому

      Thank you senpai

  • @MrPogi-lf5gz
    @MrPogi-lf5gz 5 років тому +118

    Yes to composition vs inheritance video!

  • @fernandobalino9519
    @fernandobalino9519 5 років тому +92

    I didn’t realize you could be a great programmer, a fantastic teacher, AND a supermodel at the same time. Great video.

    • @baphnie
      @baphnie 4 роки тому +1

      rofl true tho

    • @sabrinakingsley798
      @sabrinakingsley798 3 роки тому +7

      Maybe don't objectify the guy.

    • @liquidsnake6879
      @liquidsnake6879 3 роки тому +6

      @@sabrinakingsley798 Jeez, here come the witch burners lol excuse us while we all go poke out our eyes to appease your social sensibilities

    • @fernandobalino9519
      @fernandobalino9519 3 роки тому +15

      @@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.

    • @sabrinakingsley798
      @sabrinakingsley798 3 роки тому +3

      @@fernandobalino9519 Yeah, your format was compliment, compliment, AND objectification.

  • @majicboca4784
    @majicboca4784 4 роки тому +20

    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.

  • @archiee1337
    @archiee1337 2 роки тому

    The best content for SOLID on the Internet.

  • @jackhaugh4198
    @jackhaugh4198 2 роки тому

    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!

  • @SkriptKid
    @SkriptKid Рік тому +1

    You are the dom perignon of online JS educators. Clear, concise and well structured! Thanks very much for your content 🙌🏻

  • @mj65535
    @mj65535 10 місяців тому +1

    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.

  • @muhammadumair7861
    @muhammadumair7861 4 роки тому +2

    You are such a great instructor ! Finally I understand all about SOLID in just couple of minutes.

  • @rapha5210
    @rapha5210 5 років тому +4

    Uauh. I've programmed since 2000s (vb6, turbo Pascal, etc) and I still enjoy each one of your videos! Good job!

  • @kurykuryk
    @kurykuryk 5 років тому +18

    Thumbs up!!!Waiting for composition

  • @maharun
    @maharun Рік тому

    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.

  • @shayama
    @shayama 2 роки тому

    These expalmes are everywhere, really programmers cannot find more intresting expalmes...

  • @bishopshawiii7292
    @bishopshawiii7292 5 років тому +1

    Finally a simple explanation of the solid principles....👍 for composition vs. Inheritance

  • @reactdejv5562
    @reactdejv5562 5 років тому +6

    I love these SOLID principles series, nicely done man!

  • @rishabhkalra9505
    @rishabhkalra9505 5 років тому +84

    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 🎉👌

  • @davivify
    @davivify 2 роки тому +1

    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.

  • @phogbinh
    @phogbinh 5 років тому +1

    Thank you for simplifying the Liskov principle for all of us with easy-to-comprehend examples. Keep up the good work!

  • @Shinbo2
    @Shinbo2 5 років тому

    Hands down best coding channel on UA-cam. Many thanks and keep em coming!

  • @MrPauld123456
    @MrPauld123456 3 роки тому

    Thank you. As an amateur coder you have taught me tons. Thank you. Love your videos.

  • @puspamadak
    @puspamadak 3 роки тому +1

    I had never understood the concepts of OOP in my school classes. Your explanations are very easy to understand!

  • @desarrollojava
    @desarrollojava 4 роки тому +1

    And another very clear, clever and successful teaching video. Thank you!

  • @stith_pragya
    @stith_pragya Рік тому +1

    Thank You So Much for this wonderful video........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @PortEXE
    @PortEXE 3 роки тому

    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!

  • @KnightToD5
    @KnightToD5 11 місяців тому

    Great series on the SOLID principles. Your content is fantastic.

  • @robbiew4534
    @robbiew4534 5 років тому

    I appreciate your channel. This is excellent content for people reviewing for job interviews.

  • @shgysk8zer0
    @shgysk8zer0 3 роки тому

    That's one of the things I really like about PHP. You get interfaces and abstract classes and traits.

  • @ayushraj-zb6sv
    @ayushraj-zb6sv 3 роки тому

    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!

  • @marcbarbier5646
    @marcbarbier5646 4 роки тому

    thanks a lot i have exams tomorow and you just saved my day with thoses clear explaination

  • @ShujathHussain0
    @ShujathHussain0 5 років тому

    Congrats on 100K!!!
    and great explanation.

  • @sathishraj1
    @sathishraj1 4 роки тому

    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

  • @river6634
    @river6634 4 роки тому

    Excellent video. Concise and to the point. Very helpful.

  • @hyfydistro
    @hyfydistro 3 роки тому

    The bird inheritance example was so cute. Your explanations are easy to follow. You are such a great teacher. 😁👍

  • @akn9699
    @akn9699 5 років тому

    A Solid Video Concept from THE MAN - " Kyle WDS " ! We love you man and happy holidays !

  • @PhilHawkshaw
    @PhilHawkshaw 5 років тому

    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 :-)

  • @vladimirdoktorov1511
    @vladimirdoktorov1511 5 років тому +2

    Gratz for 100k

  • @suefengtan6141
    @suefengtan6141 4 роки тому

    I love your videos so much Kyle! I had trouble understanding the SOLID Principles before, and your videos are so helpful for gaining understanding!

  • @dmxd
    @dmxd 5 років тому +12

    Yes for composition

  • @jeremiahperdue5518
    @jeremiahperdue5518 10 місяців тому

    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

  • @Dylen
    @Dylen 2 роки тому

    In the modern world, we only need one guy to explain it better than our teachers to kick the exam in the nuts

  • @davidduvernay7302
    @davidduvernay7302 5 років тому

    I was craving for some good explanation about Liskov substitution. Thanks you very much!
    PS: can't wait for I on SOLID.

  • @djr2123
    @djr2123 5 років тому +1

    Yes composition video please!!

  • @philhagerman
    @philhagerman 5 років тому

    Dude first, CONGRATS ON 100k subs!!!! You earned it man. Second, yes please do composition with JavaScript

  • @kamuizero
    @kamuizero 5 років тому

    So clear and easy to understand, thank you!

  • @CapiEtheriel
    @CapiEtheriel 3 роки тому +3

    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.

    • @alexanderamante9028
      @alexanderamante9028 2 роки тому +1

      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

  • @patrickmcauliffe7162
    @patrickmcauliffe7162 4 роки тому

    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!

  • @wjsilva85
    @wjsilva85 2 роки тому

    Thank you man. Awesome class.

  • @lindawisebear
    @lindawisebear 4 роки тому

    The bird method made LSP click; great example!!

  • @niteesh__mishra
    @niteesh__mishra 5 років тому +3

    Thanks Kyle 👏

  • @av03
    @av03 5 років тому +1

    Let's go for composition

  • @sonoftroy8572
    @sonoftroy8572 5 років тому

    this is off topic, but the lighting for your UA-cam setup is made the video quality way better!!! so nice going

  • @knightmarerip711
    @knightmarerip711 2 роки тому

    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!

  • @brecoldyls
    @brecoldyls 5 років тому +3

    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!

  • @whoman7930
    @whoman7930 5 років тому +2

    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.

  • @coolcha
    @coolcha 5 років тому

    Love your videos on SOLID and I want to see a video of compositiion vs inheritence video.

  • @vlads7774
    @vlads7774 2 роки тому

    excellent explanation , thanks

  • @ExtraTurtle
    @ExtraTurtle Рік тому

    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.

  • @PlayRiteProductions
    @PlayRiteProductions 5 років тому

    More on composition please. Thanks man

  • @ManontheBroadcast
    @ManontheBroadcast 5 років тому +1

    +1 for composition over inheritance ...

  • @k1z1eMe01
    @k1z1eMe01 4 роки тому

    Great explanation. Thank you, I'm satisfied.

  • @munapadhi8723
    @munapadhi8723 5 років тому

    Best tutorials...... I love ur all videos

  • @Bomba2494
    @Bomba2494 4 роки тому

    Way better then my uni bro ty ♥

  • @GeoffreyReemer
    @GeoffreyReemer 5 років тому +2

    I'd love to sign up for Composition, too. And for more videos about the various birds in this world 🙂.

  • @artem_zakharchuk
    @artem_zakharchuk Рік тому

    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!)

  • @MrMarkgyuro
    @MrMarkgyuro 5 років тому

    i would like to hear from function compositions advantages! : )
    Great video! :)

  • @jakubczechowski1159
    @jakubczechowski1159 3 роки тому

    Thank you for the video.

  • @je9625
    @je9625 5 років тому

    Two thumbs up Kyle.

  • @milanlucansky2825
    @milanlucansky2825 5 років тому

    Yes, please do composition video.

  • @DrewSorensenMusic
    @DrewSorensenMusic 10 місяців тому

    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.

  • @himanshukarnwal880
    @himanshukarnwal880 5 років тому

    Yes please share the video on composition

  • @solar679
    @solar679 4 роки тому

    Great Video Fam.

  • @md.akib5124
    @md.akib5124 5 років тому

    love this series

  • @tushar54983
    @tushar54983 Рік тому

    @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.

  • @satyadeeproat2012
    @satyadeeproat2012 4 роки тому

    Woah. that just blew my mind

  • @InvincibleMan99
    @InvincibleMan99 4 роки тому

    nice explanation. Good voice

  • @sergeykas90
    @sergeykas90 5 років тому

    Thank you for the great explanation. Are you planning to continue this series?
    Or maybe doing series about design patterns like this?

    • @WebDevSimplified
      @WebDevSimplified  5 років тому

      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.

  • @usama57926
    @usama57926 5 років тому +1

    yes sir pls make video on composition

  • @TheWordBecameFleshJ114
    @TheWordBecameFleshJ114 2 роки тому

    Liskov Substitution Principle can be called Base Class Segregation Principle as well. :D

  • @nilen
    @nilen 2 роки тому

    Thank you brotha!

  • @y7amdy
    @y7amdy 4 роки тому +1

    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

  • @zerobit778
    @zerobit778 2 роки тому

    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).

  • @ShivamKendre-fc3su
    @ShivamKendre-fc3su 5 місяців тому

    Great video

  • @ridl27
    @ridl27 5 років тому

    you are cool bro. thx for all of your videos

  • @MI982
    @MI982 3 роки тому

    For some reason, this reminded my of Strategy pattern.

  • @Mr-Multiplayer
    @Mr-Multiplayer 5 років тому

    Composition vs inheritance 👍

  • @AISynthetic
    @AISynthetic 5 років тому +2

    Please go ahead and make a video on composition and inheritance 👍🏻

  • @shynggyskassen942
    @shynggyskassen942 3 роки тому

    GREAT VIDEOS!!!!!!!!!!!!!!

  • @64imma
    @64imma 11 місяців тому

    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?

  • @oanacristea2572
    @oanacristea2572 3 роки тому

    thank you!!

  • @MECHAJAYKUMARR
    @MECHAJAYKUMARR 2 роки тому +1

    Kindly make the video for oops concept in js

  • @firewatermoonsun
    @firewatermoonsun Рік тому

    In other words, in React, child component's props should source entirely from parent component's props?

  • @jazzmaster89
    @jazzmaster89 5 років тому

    Great video as always! Yes please, I’d love to see a video about composition vs inheritance. Awesome content!!

  • @yettodecideahandle
    @yettodecideahandle 3 роки тому

    You're the best.

  • @MrAzulay
    @MrAzulay 3 роки тому +2

    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?

    • @zuao76
      @zuao76 Рік тому

      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

  • @pierantoniodurante3892
    @pierantoniodurante3892 3 роки тому

    thank u very much !!!!!!

  • @avi12
    @avi12 3 роки тому +1

    8:25 Unless you're using C++

  • @zoecarlibur
    @zoecarlibur Рік тому

    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.

  • @r3boxx
    @r3boxx Рік тому

    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

  • @Abdallah-r9w
    @Abdallah-r9w 10 місяців тому

    You can implement more than one interface in java, that's what will solve the problem of swimming and flying bird.

  • @akashvijayasarathy6234
    @akashvijayasarathy6234 Рік тому

    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?