S.O.L.I.D First Five Object-Oriented Design OOD
S.O.L.I.D First Five Object-Oriented Design OOD
When expanded the acronyms might seem complicated, but they are pretty
simple to grasp.
S - Single-responsiblity principle
O - Open-closed principle
L - Liskov substitution principle
I - Interface segregation principle
D - Dependency Inversion Principle
Single-responsibility Principle
S.R.P for short - this principle states that:
A class should have one and only one reason to change, meaning that a class
should have only one job. When requirements change, this implies that the
code has to undergo some reconstruction, meaning that the classes have to be
modified. The more responsibilities a class has, the more change requests it
will get, and the harder those changes will be to implement. The
responsibilities of a class are coupled to each-other, as changes in one of the
responsibilities may result in additional changes in order for the other
responsibilities to be handled properly by that class.
Open-closed Principle
Objects or entities should be open for extension, but closed for modification.
You should be able to extend a class’s behaviour, without modifying it. This
principle is the foundation for building code that is maintainable and reusable.
A. High level modules should not depend upon low level modules. Both should
depend upon abstractions.
B. Abstractions should not depend upon details. Details should depend upon
abstractions.