Everything you should know about SOLID principles
Become a Better Object-Oriented Programmer: Mastering the SOLID Principles
Quick Summary of the Blog:-
About SOLID principles
Advantages/ When to use?
Disadvantages/ When not to use?
About SOLID principles:-
A set of rules that provides guidelines for writing maintainable, extensible, and testable code. By following these principles, you can create code that is easier to understand, modify, and reuse.
S: Single Responsibility Principle | 1. There should be only one reason to modify the class, which means one class should have it's clear and only one responsibility. |
O: Open/Closed Principle | 1. Classes/Entities should be open for extendibility but closed for modification. Example:- The libraries could be extended but they do not allow to modify their implementation. |
L: Liskov Substitute Principle | 1. We should be able to replace any superclass with another sub-class without affecting the existing functionality. |
I: Interface Segregation Principle | 1. Client should not be forced to implement all the methods or properties whether it is using that or not. |
D: Dependency Inversion Principle | 1. High-level modules should not depend on low-level modules, which means both should depend on abstraction. |
Advantages/ When to use? (Please follow this link-> LinkedIn Article)
Disadvantages/ When not to use? (Please follow this link-> LinkedIn Article)