SOLID Flashcards
S
Single Responsibility
“A class should have only one reason to change” which means every class should have a single responsibility or single job or single purpose
O
Open/Closed Principle
“software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification” which means you should be able to extend a class behavior, without modifying it.
L
Liskov’s Substitution Principle:
It states that objects of a derived class (subclass) should be able to replace objects of the base class (superclass) without affecting the correctness of the program. In other words, if a class B is a subclass of A, then objects of B should be able to be used wherever objects of A are expected, without causing errors or unexpected behavior.
I
Interface Segregation Principle:
It states that no client should be forced to depend on methods it does not use. In simpler terms, an interface should be small and specific to a set of related actions, rather than one large interface with many unrelated methods.
D
Dependency Inversion Principle:
It states that high-level modules should not depend on low-level modules; both should depend on abstractions
Example - Notification (high) and Email (low) service