美文网首页
Open Closed Principle

Open Closed Principle

作者: kkjusdoit | 来源:发表于2023-03-26 21:30 被阅读0次
image.png
image.png
image.png
image.png
image.png

Open-Closed Principle in C#

Implementation Guidelines for Open-Closed Principle (OCP) using C#

  1. 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.
  2. 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.

相关文章

网友评论

      本文标题:Open Closed Principle

      本文链接:https://www.haomeiwen.com/subject/jqynrdtx.html