Solid principles examples
(1) SRP : Single Responsibility Principle
A class should have one and only one reason to change, meaning that a class should have only one job.
(2) OCP : Open/Closed Principle
Classes should be open for extension, but closed for modification.
In doing so, we stop ourselves from modifying existing code and causing potential new bugs.
(3) LSP : Liskov Substitution Principle
If class A is a subtype of class B, then we should be able to replace B with A without disrupting the behavior of the program.
(4) ISP : Interface Segregation Principle
A client should never be forced to implement an interface that it doesn't use.
Clients shouldn't be forced to depend on methods they do not use.
(5) DIP : Dependency Inversion Principle
High level modules should not depend on low level modules; both should depend on abstractions.
Abstractions should not depend on details. Details should depend upon abstractions.
Tools
: vs22, .net6