Open-Closed Principle
The approach for designing and eventually writing production code should be the one that allows new functionalities to be added to a project's code base without having to make many changes, change several portions or classes of the code base, or break existing functionalities that were already working and in good condition.
If, for any reason, you make changes to a method in a class and as a result of the changes, changes have to be made to several parts or modules, it's an indication of a problem with the code design. This is what the Open-Closed Principle (OCP) addresses, to allow your code base design to be flexible, so that you can easily make modifications and enhancements.
The OCP states that software entities, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access