A SOLID Guide to SOLID Principles
SOLID principles are kind of a design principals.They help to manage most of the software design principles.
There are five design principles that used to develop software more understandable, flexible and maintainable.
SOLID principles are designed by Robert C. Martin
Michael Feathers introduced the SOLID acronym.
Explanation of SOLID principles
- Single Responsibility Principle
One Class and one member must do the one task.That task should not do the multiple tasks at a given time.One responsibility must be done by the given class or member.
- Liskov Substitution Principle
In programme language we use common functionality in the project,To gain this common functionalities we use the inheritance,Then there must be a relationship between child and parent.This concept shows the way to do it.It tells What type of technoliest should we use and what standards that we should use.
- Open/Closed Principle
When we are adding new functionality.we add new classes,methods and attributes.We do not add that functionality to the same class or method.Some time requirement may changes.Therefore we don’t change the existing functionality .We have to implement new logic for this.
If we implement a new logic to the same class.Maintenance will be difficult,There may be a multiple duplicate code.Testing may be difficult.
- Interface Segregation Principle
This concept talks about the interfaces in OOP concept.We can use multiple interfaces without using the big ,complex interface.We can break the interface to the small interface throughout the project.We can use them as sub modules.
- Dependency Inversion Principle
This concept talks about the high level module and the law level module.High level module does not depend on the low level modules.There is no direct connection between low level module and the high level module.There is an agent between them.That agent keep the communication between them.As example There is a middle layer between business layer and data access layer .Therefore we can achieve loose coupling feature in programming language.
Advantages of SOLID Principles
- Can achieve loose coupling
- Can achieve testing
- Reduce the complexity of code.
- Increase the testability
If we don’t follow SOLID Principles we
- Maintenances may be difficult
- There are duplication code.
- Create new bug when fixing bugs
- There are new unknown issues.
- Testing is harder.