This document discusses the five SOLID principles of object-oriented design: single responsibility principle, open-closed principle, Liskov substitution principle, interface segregation principle, and dependency inversion principle. The single responsibility principle states that a class should have one responsibility. The open-closed principle specifies that classes should be open for extension but closed for modification. The Liskov substitution principle indicates that objects should be replaceable with their subtypes without altering program correctness. The interface segregation principle promotes separating general interfaces into specific ones for client needs. Finally, the dependency inversion principle establishes that high-level modules should not depend on low-level ones but instead both should depend on abstractions.
2. SOLID
SOLID are five basic principles which help to create good software
architecture. SOLID is an acronym where:-
S stands for SRP (Single responsibility principle)
O stands for OCP (Open closed principle)
L stands for LSP (Liskov substitution principle)
I stands for ISP ( Interface segregation principle)
D stands for DIP ( Dependency inversion principle)
3. 1 - Single responsibility principle
SRP says that a class should have only one responsibility and
not multiple.
6. 2-Open closed principle
Open/Closed principle says that a class should be open for
extension but closed for modification. Which means that
you can add new features through inheritance but should
not change the existing classes.
9. 3-Liskov substitution principle
" The Liskov Substitution Principle says that the object of a derived
class should be able to replace an object of the base class without
bringing any errors in the system or modifying the behavior of the
base class. "
it means that we must make sure that new derived classes are
extending the base classes without changing their behavior.
objects in a program should be replaceable with instances of their subtypes
without altering the correctness of that program.
13. 4-Interface segregation principle
The Interface Segregation Principle states that clients should not be
forced to implement interfaces they don't use. Instead of one fat
interface many small interfaces are preferred based on groups of
methods, each one serving one submodule.
No client should be forced to depend on methods it does not use.
Many client-specific interfaces are better than one general-purpose interface.
Show only those method/functionality to the client which they want rather than
showing all the functionality
16. 5-Dependency inversion principle
DIP states that how two modules should depend on each
other.
A. High-level modules should not depend on low-level modules. Both should depend on
abstractions.
B. Abstractions should not depend upon details. Details should depend upon
abstractions.