用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
## **Open Closed Principle** ## **Introduction** ## Over the life time of an application, more time is spent adding to the existing codebase rather than constantly adding new features from scratch. As you are probably aware, this can be a tedious and frustrating process. Anytime you modify code, you risk introducing new bugs, or breaking old functionality completely. Ideally, we should be able to modify an existing codebase as quickly and easily as writing brand new code. If we correctly design our application according to the Open Closed principle, we can just do that! > ### **Open Closed Principle** ### > > The Open Closed principle of SOLID design states that code is open for extension but closed for modification. > ## **In Action** ## To demonstrate the Open Closed principle, let's continue working with our OrderProcessor from the previous chapter. Consider the following section of the process method: