I have recently been trying to learn about basic design principles and the OCP has me a bit confused. It makes sense that when a change happens it is preferable to extend the system rather than modify existing and working parts. But isn't this more of a principle for how to implement changes in a system rather than how to design one? Isn't all code basically open for extension by using subclassing? And how can any code be closed for modification - doesn't that just depend on how the person implementing a change chooses to use it?
Perhaps an example of some code that doesn't follow the OCP and how exactly it has violated the principle would be the most helpful for me to understand this.
Thanks