What is the meaning and reasoning behind the Open/Closed Principle?

后端 未结 14 1191
死守一世寂寞
死守一世寂寞 2020-12-02 08:31

The Open/Closed Principle states that software entities (classes, modules, etc.) should be open for extension, but closed for modification. What does this mean, and why is i

14条回答
  •  爱一瞬间的悲伤
    2020-12-02 09:04

    The principle means that it should easy to add new functionality without having to change existing, stable, and tested functionality, saving both time and money.

    Often, polymorhism, for instance using interfaces, is a good tool for achieving this.

提交回复
热议问题