I was reading a text about SOLID principles and Open/Close principle and it said that : “The main idea of this principle is to keep existing code from breaking when you implement new features”
what it means by breaking code?
Advertisement
Answer
You “break” existing code when you modify it in a way that prevents it from working for existing or intended use cases, when it worked fine for those use cases before you modified it.
By writing your code so that it is open for extension, but closed for modification, you allow the code to be used in new situations without having to modify it. No modification = no breaking.