What is Liskov Substitution Principle ?

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024
  • 1. Full .NET Interview Course (with PDF Book)
    C# / ASP.NET Core / MVC / API - Top 500 Interview Questions
    www.udemy.com/...
    Don't worry if course not helping you, Udemy has 30 days Free Refund Policy.
    2. Quick Revision Book (PDF format)
    Top 500 .NET Interview Questions - OOPS/ C#/ ASP.Net/ MVC/ SQL /.Net Core /Web API
    imojo.in/inter...
    3. (Outside India )Quick Revision Book (PDF format)
    Please mail at anuragrawat123@gmail.com
    50% Discount Applied on above link.
    Don't worry if book not helping you, I will return 100% of your money with in 7 days of purchase. Just mail me at anuragrawat123@gmail.com.
    My best wishes are with you.

ความคิดเห็น • 57

  • @shenth27
    @shenth27 4 หลายเดือนก่อน +2

    This example violates LSP because you're throwing NotImplementedException but you can instead returns 0 bonus for ContractualEmplyeee and avoid the error.

    • @visarad
      @visarad 4 หลายเดือนก่อน

      same question

    • @surajmangalekar4370
      @surajmangalekar4370 3 หลายเดือนก่อน +3

      0 has a value, business perspective we should not provide anything for contract employees

    • @akdigitalmedialive
      @akdigitalmedialive 3 หลายเดือนก่อน

      Returning 0 means there is salary component bonus which is wrong. Also think about maintaining this method in long term

  • @manishackadam
    @manishackadam 7 หลายเดือนก่อน +1

    Awesome!! understood n will remain permanent in my memory

  • @nayankulkarni5131
    @nayankulkarni5131 6 หลายเดือนก่อน

    What a absolute simple explaination!

  • @anooprawat1006
    @anooprawat1006 ปีที่แล้ว +8

    What if you return 0 bonus, instead of throwing exception?, Does it fix Liskov ?

    • @prakash13565
      @prakash13565 17 วันที่ผ่านมา

      no it will not as you are breaking the functionality here. See for caluclating a salary we have a particular formula same for bonus and that method will be defined in the parent class. Here in the video he said he is not caluclating just returning the values it means formula will be same for all the employees. But in case for contract employe we cant give bonus and we have to redefine the defination of that bonus method which is wrong.

  • @ravindrareddy-x7p
    @ravindrareddy-x7p หลายเดือนก่อน

    great explanation

  • @khilanunadkat3865
    @khilanunadkat3865 ปีที่แล้ว +1

    Excellent explanation. Thank you

    • @interviewhappy
      @interviewhappy  ปีที่แล้ว

      Thanks. Glad you liked it. Wish you all the best for your career.

  • @MuhammadKashif-wh1us
    @MuhammadKashif-wh1us ปีที่แล้ว

    just one word : Thanks

  • @sauravpati8597
    @sauravpati8597 ปีที่แล้ว

    can you make some videos on Architecture interview questions

  • @compman73
    @compman73 6 หลายเดือนก่อน

    Not a correct explanation of LSP
    You need to cast child to parent variable

  • @ravindran7956
    @ravindran7956 ปีที่แล้ว

    I feel this is not proper example for LSP

  • @happymalyo_
    @happymalyo_ ปีที่แล้ว +12

    Your tutorial is incredibly clear and well-organized! Keep creating more video like this

    • @interviewhappy
      @interviewhappy  ปีที่แล้ว +2

      Thanks buddy and all the best for your career.

  • @ankitaburman5406
    @ankitaburman5406 ปีที่แล้ว +6

    Excellent Explaination Sir. Thank you so much for videos on Solid Principles

    • @interviewhappy
      @interviewhappy  ปีที่แล้ว

      Thanks Ankita and all the best for your career.

  • @nathanyt
    @nathanyt 11 หลายเดือนก่อน +2

    A better example would be something like this:
    - You have a function that accepts an Employee object ---- *void CalcSalary(Employee e) { e.CalculateSalary() }*
    - If you are following LSP, if I pass a subclass object to that function, the program should sill work. Example: *CalcSalary(new PermanentEmployee())*

  • @User-Dotnet
    @User-Dotnet 2 หลายเดือนก่อน

    What will happen if we not Override Bonus Method in ContractualEmployee Class? What will happen if we declare only Calculate salary because Bonus method already override in PermanentEmploye Class right!

  • @muhammadadil7307
    @muhammadadil7307 หลายเดือนก่อน

    Sir its humble request plz make video on deep and shallow copy

  • @na2599
    @na2599 18 วันที่ผ่านมา

    we can say that LSP is same as Interface segragation Principal?

  • @aneesmohammed7978
    @aneesmohammed7978 11 วันที่ผ่านมา

    Hi. Superb explanation. You have explained in clarity and simple words which I hardly found from others

    • @interviewhappy
      @interviewhappy  10 วันที่ผ่านมา

      Thank you so much 🙂

  • @ijaztufail8000
    @ijaztufail8000 ปีที่แล้ว +4

    Very good sir keep it up. You are explaining at its best. Please upload repository patterns series after this series

    • @interviewhappy
      @interviewhappy  ปีที่แล้ว

      Thanks @ ijaz Will try to do it.

    • @ijaztufail8000
      @ijaztufail8000 ปีที่แล้ว

      @@interviewhappy Welcome. And one more thing please make videos on some programmatic/written questions for experienced developer like in SQL and C# LINQ or other type of test questions

  • @mayankpriyadarshi9346
    @mayankpriyadarshi9346 2 หลายเดือนก่อน

    I am confused you have created object of pEmployee.calculateBonous and saying this follow LSP. Help me to correct if CalculateBonous will be there in PermanentEmployeeClass as it is there in base class then only it follows LSP.
    LSP : whatever methods is there in parent class that should be there in child class and child class should not change the behavior of parent class object .

  • @rktamilarasi2442
    @rktamilarasi2442 6 หลายเดือนก่อน

    I have one doubt
    We can't use the CalculateBonus() method in ContractualEmployee class but it is basically have the method of CalculateBonus() through inheritance.
    Then my question is how to use CalculateBonus () method in ContractualEmployee class and ContractualEmployee class object?

  • @adventurer2395
    @adventurer2395 9 หลายเดือนก่อน +4

    this is a better example of interface segregation than LSP

  • @zeez7777
    @zeez7777 5 หลายเดือนก่อน

    Why not just return 0 for the bonus?

  • @haidernaqvi87
    @haidernaqvi87 ปีที่แล้ว +1

    It is somewhat similar to interface segregation principle. Because contractaul employee were forced to implement bonus method which it doesn’t need

    • @interviewhappy
      @interviewhappy  ปีที่แล้ว

      It is bit similar but not the same.

  • @sweetu246
    @sweetu246 3 หลายเดือนก่อน

    Sir ,Videos really helped me to understand the concepts,Please create azure tutorial as well

  • @Gauravkumar-jm4ve
    @Gauravkumar-jm4ve ปีที่แล้ว +1

    Very good pls upload more, thanks so much for sharing ur valuable knowledge

    • @interviewhappy
      @interviewhappy  ปีที่แล้ว

      Thanks Gaurav and all the best for your career.

  • @srikanth29
    @srikanth29 ปีที่แล้ว

    If we return 0 in the bonus method of contractEmployees method then we wont' voilate.

  • @anandafit6
    @anandafit6 6 หลายเดือนก่อน

    what are the practical scenarios we need to replace supertype from subtypes?

  • @sanmathi3968
    @sanmathi3968 7 หลายเดือนก่อน

    Awesome. Really helped. Please create videos for design patterns 😊

  • @S-yf5te
    @S-yf5te 10 หลายเดือนก่อน

    The above example is for bad design how to fix it?

  • @rishavraj3127
    @rishavraj3127 5 หลายเดือนก่อน

    Simply WOW 👌👌👌👌

  • @chandusrinivas7813
    @chandusrinivas7813 6 หลายเดือนก่อน

    Wow, very simple and best example, Great explanation.
    Thanks Bro.

  • @chirasreepal2672
    @chirasreepal2672 2 หลายเดือนก่อน

    simple and clear explanation :)

  • @ravichandra786
    @ravichandra786 ปีที่แล้ว +1

    Good explanation😊

  • @sureshkumar5103
    @sureshkumar5103 4 หลายเดือนก่อน

    Well explained. Thanks a lot.

  • @Skgupta2353
    @Skgupta2353 ปีที่แล้ว

    yes sure

  • @jsm33t
    @jsm33t ปีที่แล้ว

    Thankyou!!!!!!

  • @biswajitmishra3461
    @biswajitmishra3461 11 หลายเดือนก่อน

    excellent