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.
This example violates LSP because you're throwing NotImplementedException but you can instead returns 0 bonus for ContractualEmplyeee and avoid the error.
same question
0 has a value, business perspective we should not provide anything for contract employees
Returning 0 means there is salary component bonus which is wrong. Also think about maintaining this method in long term
Awesome!! understood n will remain permanent in my memory
What a absolute simple explaination!
What if you return 0 bonus, instead of throwing exception?, Does it fix Liskov ?
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.
great explanation
Excellent explanation. Thank you
Thanks. Glad you liked it. Wish you all the best for your career.
just one word : Thanks
Your Welcome @kashif
can you make some videos on Architecture interview questions
Not a correct explanation of LSP
You need to cast child to parent variable
I feel this is not proper example for LSP
np
please provide your version of LSP sir, so that we all can learn.
Your tutorial is incredibly clear and well-organized! Keep creating more video like this
Thanks buddy and all the best for your career.
Excellent Explaination Sir. Thank you so much for videos on Solid Principles
Thanks Ankita and all the best for your career.
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())*
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!
Sir its humble request plz make video on deep and shallow copy
we can say that LSP is same as Interface segragation Principal?
Hi. Superb explanation. You have explained in clarity and simple words which I hardly found from others
Thank you so much 🙂
Very good sir keep it up. You are explaining at its best. Please upload repository patterns series after this series
Thanks @ ijaz Will try to do it.
@@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
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 .
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?
this is a better example of interface segregation than LSP
Why not just return 0 for the bonus?
It is somewhat similar to interface segregation principle. Because contractaul employee were forced to implement bonus method which it doesn’t need
It is bit similar but not the same.
Sir ,Videos really helped me to understand the concepts,Please create azure tutorial as well
Very good pls upload more, thanks so much for sharing ur valuable knowledge
Thanks Gaurav and all the best for your career.
If we return 0 in the bonus method of contractEmployees method then we wont' voilate.
what are the practical scenarios we need to replace supertype from subtypes?
Awesome. Really helped. Please create videos for design patterns 😊
The above example is for bad design how to fix it?
Simply WOW 👌👌👌👌
Thanks a lot 😊
Wow, very simple and best example, Great explanation.
Thanks Bro.
Glad you liked it!
simple and clear explanation :)
Good explanation😊
Thanks @ Ravi . Glad You Liked it
Well explained. Thanks a lot.
Glad you liked it
yes sure
Thankyou!!!!!!
You're welcome! @JSM33TMUSIC
excellent