Improve your understanding of SOLID principles in OOPS.
Ratik Mahajan
Posted on August 26, 2024
What Does Solid principles mean ?
- S-> Single responsibility principle : it states that a class or an object in the OOPS programming realm should carry only one responsibility. if there are actions that are taken by student
- pay for the fees
- enrolment to new course
- subjects studying
Assume we can create a class with all the responsibility encapsulated in student class, but that would make our code complex and difficult to maintain.
we have to separate the concerns and make sure that each class is only responsible for one task . this way each class will perform task.
O-> Open and closed principle :
This principle states that we should not change existing functionality or program in the class. we can extend our functionality of the class, but we shouldn't be able to modify it.
this looks really easy while we write it in theory, but we have to think of creating interface and make sure that we even if new classes are added, they implement from the interface and are able to execute the existing core logic.
Posted on August 26, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.