Liskov Substitution Principle in Object Oriented Design | SOLID Principles
ฝัง
- เผยแพร่เมื่อ 27 ก.ค. 2024
- In this video we will cover Liskov Substitution Principle of object oriented design.
It is one of the SOLID principles.
This principle states that objects of super class should be substitutable with the objects of the sub class.
OR
The properties and behavior of sub-class inherited from the super-class are substitutable with the properties and behavior of super-class.
You will understand important concepts of Object oriented programming such as encapsulation and inheritance and commonly asked interview questions.
🔗Website:
Full Course: www.thinkxacademy.com/Object%...
🔗Download Android App(Notes+Videos): play.google.com/store/apps/de...
🌐Join our community:
Facebook: / thinkxacademy
Twitter: / thinkxacademy
Instagram: / thinkxacademy
Very well explained.
very good teaching approach🪅♥
Good Explanation with Visual
thanks😄like and share
Can you also please explain how will you solve the shape,circle,square and rectangle problem ¿
Great and clear explanation @ThinkX Academy
The answer to this lies in next video of this course i.e. Interface Segregation (hint: Encapsulate what varies)
@@ThinkXAcademy is this how we do it¿
interface Shape{
void area();
}
Class Rectangle implements Shape{
int length;
int breadth;
Rectangle(int l,int b){
length =l,
breadth=b;
}
@override
void area(){
System.out.println(length*breadth);
}
}
Class Square implements Shape{
int area;
Square(int a){
area=a;
}
@override
void area(){
System.out.println(area*area);
}
}
Correct now area() is not coupled with shape class and every subclass has its own implementation. This concept is loose coupling.
@@ThinkXAcademy Shape is an interface in my code and not a class.
As per my understanding the two classes rectangle and square are loosely coupled and shape is an interface.
Please correct me if I'm wrong
You can make shape a class then only inheritance is possible and create an interface calculateArea.