http://www.cnblogs.com/wangkunyu/archive/2013/07/22/3206477.html
“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:
例子:玉帝招安美猴王
当年大闹天宫便是美猴王对玉帝的新挑战。美猴王说:"'皇帝轮流做,明年到我家。'只教他搬出去,将天宫让于我!"对于这项挑战,太白金星给玉皇大帝提出的建议是:"降一道招安圣旨,宣上界来…,一则不劳师动众,二则收仙有道也。"
换而言之,不劳师动众、不破坏天规便是"闭",收仙有道便是"开"。招安之道便是玉帝天庭的"开放-封闭"原则。
招安之法的关键便是不允许更改现有的天庭秩序,但允许将妖猴纳入现有秩序中,从而扩展了这一秩序。用面向对象的语言来讲,不允许更改的是系统的抽象层,而允许更改的是系统的实现层。