Software design is a mechanism to transform user requirements into an appropriate form, which assists the programmer in the coding and implementation of software.
SOLID Principle is an initialism for 5 design principles in Software Engineering. These principles were first introduced by Robert Martin.
Let’s see what are the 5 design principles…
Single Responsibility Principle
Simply, the single responsibility principles defines that, a class should have only one responsibility.
This principle states that every object in the system should have only a single responsibility and all of the objects should focus on achieving that particular responsibility.
If you are being stick to this principle through your code, it can be easily modified. Moreover, the code will be easier to be followed, understood, debugged, removed, and refactored.
Open Closed Principle
This principle states that, a class or a method should be opened for extension (i.e. adding new functionality) but closed for modifications.
How Can We DO That???🤔
Using the help of abstract classes and interfaces, we can add new functionality without touching the existing code for the class.
Liskov Substitution Principle
This Principle explains that, every subclass should be able to substitute their base class.
Here, the child class should:
- perform basic functionalities of the base class when extended
- not have unimplemented methods
- not give different meaning to the base class after overriding
Interface Segregation Principle
This Principle defines that, the clients should not be forced to implement the methods that they do not use.
Therefore, we need to create subtle interfaces that are client-specific.
Dependency Inversion Principle
This principle defines that,
- Higher level modules should not depend on lower level modules but they should depend on abstractions.
- Abstractions should not depend on details. Details (i.e. concrete implementations) should depend on abstractions.
We just briefly learned what is SOLID in software engineering.
That’s it for now, and please press the clap button if you find this article helpful.