5. What is Liskov substitution principle?
Child classes should not break the parent
class's type definitions.
Liskov SubstitutionPrinciple
https://htree.plus/
6. What is breaking the rule of Liskov principle?
In below class diagram we cannot withdraw from kids account and that will create an exception in
superclass withdrawal method. That is a breach in Liskov Substitution Principle.
❌ Withdraw method in the kids account class is a breach
of LSP
✔️ Handling Non withdrawable behaviour by introducing two
new classes inheriting base class.
https://htree.plus/
7. Interface-segregation principle (ISP) states that :
“Client should not be forced to depend on methods it does not use.”
Why ISP is needed?
● Fat Interface
Interface Segregation Principle
https://htree.plus/
8. What ISP suggests?
● Role Interfaces
Advantages :
● Small, highly cohesive and
“Solid” classes
● increases readability and maintainability
https://htree.plus/
9. Dependency Inversion Principle
Dependency Inversion Principle states that:
“Entities must depend on abstractions not on concretions”
What does it says?
● High level modules
● Low level modules
https://htree.plus/
11. Conclusion:
By applying these 5 principles that make the SOLID acronym, we get to benefit from a
reusable, maintainable, scalable and easy testable codebase.
https://htree.plus/