- Design Patterns and Best Practices in Java
- Kamalmeet Singh Adrian Ianculescu LUCIAN PAUL TORJE
- 188字
- 2021-06-25 20:52:30
Open/closed principle
This principle is as follows:
"Modules, classes, and functions should be open for extension but closed for modifications."
Applying this principle will help us to develop complex and robust software. We must imagine the software we develop is building a complex structure. Once we finish a part of it, we should not modify it any more but build on top of it.
When developing software, it's the same. Once we have developed and tested a module, if we want to change it, we must test not only the functionality we are changing but the entire functionality it's responsible for. That involves a lot of additional resources, which might not have been estimated from the beginning, and also can bring additional risks. Changes in one module might affect functionality in others or on the whole. The following is a diagrammatic representation:

For this reason, best practice is to try to keep modules unchanged once finished and to add new functionality by extending them using inheritance and polymorphism. The open/closed principle is one of the most important design principles being the base for most of the design patterns.
- Software Defined Networking with OpenFlow
- JavaScript語(yǔ)言精髓與編程實(shí)踐(第3版)
- Linux核心技術(shù)從小白到大牛
- C語(yǔ)言程序設(shè)計(jì)
- GitLab Repository Management
- 老“碼”識(shí)途
- 小學(xué)生C++創(chuàng)意編程(視頻教學(xué)版)
- Learning OpenStack Networking(Neutron)(Second Edition)
- PHP編程基礎(chǔ)與實(shí)例教程
- 從零開始學(xué)C#
- Learning YARN
- “笨辦法”學(xué)C語(yǔ)言
- SQL Server 2016 從入門到實(shí)戰(zhàn)(視頻教學(xué)版)
- Managing Microsoft Hybrid Clouds
- 從“1”開始3D編程