S: S stands for single responsibility principle.Each class is responsible for single responsibility.
O: Class shall be open for extension but closed for modification.
L: L stands for Liskov substitution.This means that objects of superclass shall be replaced with objects of subclasses without breaking the system.
I: I stands for Interface segregation Principle. This means that Interface shall not have unnecessary methods which need to be implemented by client forcefully. So if there are methods which are not always required by clients so better would be to keep them in separate interface and the clients which want those can override those methods by implementing different interface.
D: D stands for dependency inversion principle.It states that class shall depend on abstract reference(abstract class or interface) rather than concrete implementation(class) . Here , inversion refers to the dependent classes on which another class depends. In simple terms we shall use abstract classes or interface as dependency to one class not concrete classes.
For eg
Class Car{
Engine engine// This Engine either has to be abstract class or interface.
}
No comments:
Post a Comment