Opening and closing principle OCP (Open for extension,closed for modification). The core idea of open and close principle is that an object is opened to expansion and closed to modification.
In fact, the opening and closing principle means that changes to the class are made by adding code rather than altering the existing code. In other words, once the software developer writes out the code that can be run, it should not change it, but to ensure that it can continue to run, how to do this? This requires the help of abstraction and polymorphism, that is, to abstract the content of the possible changes, so that the abstract part is relatively stable, and the specific implementation layer can be changed and extended.
According to the open and close principle, when we change a software (such as extending other functions), we should make the software change by means of extension, instead of modifying the original code to realize the change.
Design principles in architecture open and close (OCP)-Java Development Technology-experience the beauty of design patterns and algorithms in architecture