Short Notes — SOLID Principles
SOLID principles are integral part of application development when it comes to understanding design patterns and improve the quality of code, and writing clean code.
Writing clean code is a very important skill that can make you stand out in your competition.

1. Single Responsibility
A class should do only one thing and should have one reason to change. For example, we have a class Student which represents one of the data models of the project, the class should change only when there is a change in the data modal.
Benefits of using SRP
It makes code more readable, easily understandable to other developers, and loosely coupled, this is a very important step to writing clean code.
- It makes version controlling easy – as when you work in a team or on big projects, multiple developersq have to work on the same files, if SRP is followed there will be one reason the file will get changed and other people will be able to understand it quickly.
- It also results in fewer conflicts when merging code from different devs, as there is a single reason for the change and it’s easier to resolve conflicts.
- Your code looks clean, which makes it easy to get it reviewed, debugging clean code can minimize the time to resolve bugs.
- Introducing new changes is also easy as you will be aware of all the classes and the things it’s doing.
2. Open/Closed
This principle states that a class should be open for extension and closed for modifications. This simply means that while introducing new functionalities we should introduce new methods instead of doing changes in existing code.
Benefits of using open/closed principle-
- By not touching the happy code we are already reducing the chances of potential bugs which might come if we make changes to existing working code.
- Easier to write test cases for newly introduced code or implementation.
3. Liskov substitution
The Liskov Substitution Principle states that an instance of a parent class should be replaceable with an instance of a child class. In simple terms, An overridden method of a subclass needs to accept the same input parameter values as the method of the superclass.
Benefits of using Liskove substitution
- More readable code
- No misleads, clean code
4. Interface segregation
Interface segregation simply means that larger interfaces should be split into multiple smaller ones.
Benefits if Interface segregation
- By doing so, we can ensure that implementing classes only need to be concerned about the methods that are of interest to them
- It prevents classes to implement only necessary methods.
5. Dependency inversion
High-level modules which provide complex logic should be easily reusable in low-level modules, To achieve that, you need to introduce an abstraction that decouples the high-level and low-level modules from each other.
Benefits of Dependency inversion
- This enables you to change higher-level and lower-level modules without affecting any other classes, as long as you don’t change any interface abstractions
If you find this article useful give a clap and follow.
Check out my other article –