S.O.L.I.D.
Solid Principal Aims at designing application architecture in such a way so any new change made to application will not induce any defect
S - Single Responsibility
O - Open and Close Principal - Abstract class could be extended without breaking or changing existing code
L - Liskov Substitution Principle - Ensure subclass follow contract of parent class using Inheritence.
I - Interface Segregation Principal - Use Mulitple Interfaces instead of Single Large Interface
D - Dependency Inversion Principal - Use Dependency Injection and Interfaces to Depend on Abstraction.
Example to demonstrate Liskov
abstract class Vehicle {
abstract void start();
}
class Car extends Vehicle {
@Override
void start() {
System.out.println("Car is starting...");
}
}
public class Main {
public static void main(String[] args) {
Vehicle myCar = new Car();
myCar.start();
}
}
References :
Comments
Post a Comment