DEV Community

Discussion on: Open/Closed Principle

satansdeer profile image
Maksim Ivanov Author

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.

enriquemorenotent profile image
Enrique Moreno Tent

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".