Seekershive Minds
Seeker’s Hive
Published in
Mar 2, 2022

Open Closed Principle

It states that the classes are “Open for extension but Closed for modification”.

A class which was already unit tested and deployed to production should be avoided from further modifications.

Continuous or regular modifications might lead to State Space Explosion.

It affects the maintainability and scalability of our code.

So what’s the solution?

Instead we go for extension, in code terms we inherit classes or use specification pattern.

With Specification pattern we can have separate classes for each functionality. This is closely related with the Single Responsibility Principle.

If you want to know about single responsibility principle, do check out in this link – https://medium.com/seekers-hive/single-responsibility

Thanks for reading through the article. Follow for more.

--

--