Grasp SOLID Principles in one minute
SOLID Principles is a coding standard that all developers should have a clear concept for developing software in a proper way to avoid bad design.
S — Single-responsibility principle
O — Open-closed principle
L — Liskov substitution principle
I — Interface segregation principle
D — Dependency Inversion Principle
Single-responsibility principle
A class or method should have only one responsibility.
Meaning that A class or method should have one and only one reason to change.
Open-closed principle
Objects or entities should be open for extension, but closed for modification.
This simply means that a class should be easily extendable without modifying the class itself. The virtual and override keywords allow you to do so.
Liskov substitution principle
Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.
All this is stating is that every subclass/derived class should be substitutable for their base/parent class.
Interface segregation principle
A client should never be forced to implement an interface that it doesn’t use or clients shouldn’t be forced to depend on methods they do not use.
Split interfaces until it has only the necessary methods that implementer needs.
Dependency Inversion Principle
Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.
This principle allows loosely-couple of components and is the principle of the Dependency Injection technique.