SOLID - jellyfish-tom/TIL GitHub Wiki
[SOURCES]
- https://stackify.com/dependency-inversion-principle/
- https://en.wikipedia.org/wiki/Interface_segregation_principle
- https://en.wikipedia.org/wiki/Dependency_inversion_principle
SOLID is an acronym for five words describing rules to write good ObjectOriented (and not only) code:
S - Single Responsibility Principle
Your class/method should do/be responsible for one thing only.
O - Open/Close Principle
Your class/method should be open to extension without the need of modifications.
L - Liskov Substitution Principle
Your code should work well with class it works with/interfaces/derive and with all its subclasses. Or (from another side) if your method works with some interface, all its implementations should work well with that method.
In other words. If your code uses some other code and implementation of that other code changes (functionality stays the same, communication protocol etc. as well) your class should need no change.
I - Interface Segregation Principle
No client should be forced to depend on methods it does not use. ISP splits interfaces that are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them
D - Dependency Inversion Principle
High-level modules, which provide complex logic, should be easily reusable and unaffected by changes in low-level modules, which provide utility features. To achieve that, you need to introduce an abstraction that decouples the high-level and low-level modules from each other.
- High-level modules should not depend on low-level modules. Both should depend on abstractions.
- Abstractions should not depend on details. Details should depend on abstractions. By dictating that both high-level and low-level objects must depend on the same abstraction this design principle inverts the way some people may think about object-oriented programming.