One of the main principles of OOD (Object Oriented Design) is SOLID principles. SOLID is stands for :
1. Single Responsibility Principle:
This means the class has to have one and only one reason to responsibility. This responsibility should be encapsulated by the class.
2. Open/closed principle:
The open/closed principle states that software entities (classes, modules, functions, …etc) should be open for extension, but not for (closed) modification
This will be very helpful on the production environment where fixing and enhancing certain area is required without affecting other areas. thus you will go with extending the class and its behaviors without modifying the current existing code/methods
3. Liskov substitution principle:
means Substitute-ability; It states that, if SubclassA is a sub-type of MainTypeA, then objects of type MainTypeA may be replaced with objects of type SubclassA without altering any of the properties of that program
4. Interface segregation principle:
The main goal from this point is to make the software more maintainable and loosely coupled; thus easier to re-factor and change. Basically, we need to split the large interfaces into smaller interfaces so that the client classes will be aware of the methods/properties they concern about
5. Dependency inversion principle:
It is about decoupling software layers and making sure the software is loosely coupled. Basically this principle states 2 things:
– High-level modules/layers should NOT depend on low-level modules/layers. communication between modules and layers should go through abstractions.
– Abstractions should NOT depend on details and the Details should depend on abstractions.