![](https://img.haomeiwen.com/i8826670/4f1805d26829ba64.png)
![](https://img.haomeiwen.com/i8826670/b0950d6c1699d89a.png)
![](https://img.haomeiwen.com/i8826670/5158316343d7849b.png)
![](https://img.haomeiwen.com/i8826670/acce1d0de80c5cd1.png)
![](https://img.haomeiwen.com/i8826670/1ca45bb80a26eb7f.png)
Implementation Guidelines for Open-Closed Principle (OCP) using C#
- The easiest way to implement the Open-Closed Principle in C# is to add new functionalities by creating new derived classes which should be inherited from the original base class.
- Another way is to allow the client to access the original class with an abstract interface.
So, at any given point in time when there is a change in requirement or any new requirement comes then instead of touching the existing functionality, it’s always better and suggested to **create new derived classes ** and leave the original class implementation as it is.
网友评论