"open-close"prinple (OCP)_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > "open-close"prinple (OCP)

"open-close"prinple (OCP)

 2013/7/22 22:40:40  小雨or小玄  博客园  我要评论(0)
  • 摘要:1."open-close"prinple(OCP)Open-ClosedPrincipletellsthat:asoftwareentityshouldopentoextendandclosetomodify.advantage:byextendingexistingsoftwaresystem,wecanoffernewactions,inordertomeetnewmeettosoftware
  • 标签:

1. "open-close"prinple (OCP)

    Open-Closed Principle tells that:a software entity should open to extend and close to modify.

advantage:

      by extending existing software system,we can offer new actions,in order to meet new meet to software,so that the changing software has more adaption and flexibility.

       already exiting module,especially the most important abstract level module that can not be modified,which makes the software system in changing has more stability and continuity.

for example:

例子:玉帝招安美猴王 
当年大闹天宫便是美猴王对玉帝的新挑战。美猴王说:"'皇帝轮流做,明年到我家。'只教他搬出去,将天宫让于我!"对于这项挑战,太白金星给玉皇大帝提出的建议是:"降一道招安圣旨,宣上界来…,一则不劳师动众,二则收仙有道也。" 
换而言之,不劳师动众、不破坏天规便是"闭",收仙有道便是"开"。招安之道便是玉帝天庭的"开放-封闭"原则。

      招安之法的关键便是不允许更改现有的天庭秩序,但允许将妖猴纳入现有秩序中,从而扩展了这一秩序。用面向对象的语言来讲,不允许更改的是系统的抽象层,而允许更改的是系统的实现层。

  • 相关文章
发表评论
用户名: 匿名