Skip to content

re: Open/Closed Principle VIEW POST


While I understand the principle, I am unsure of what is the point of it. What are we trying to achieve following this principle? What is the benefit?


The point is to be able to extend system for cheap. So you won't have to make changes to your class/module every time you need to extend it. So this approach allows you to keep complexity low.


Maybe i am missing something important here.

How does "not having to make changes to your classes" help to keep complexity low?

In the example you gave about the cookie machine, I would agree. It is a good way to extend the possibilities of the CookieMachine class, and it seems more flexible, but it actually seems to me like the complexity is bigger, than just adding a new "case".

code of conduct - report abuse