一些笔记。

  • strategy : facilitates the switch of the different but related algorithms/behaviors
  • observer
  • proxy : controls the access to the real subject ; shares the common interface with the real subject and sometimes provides a subset of the operations in the interface (in the case of the protection proxy)
     e.g. there are three kinds of proxies : (1) the remote proxy (surrogate the subject in the different address space); (2) the virtual proxy (SqlSessionTemplate in the mybatis.spring which is a proxy of the SqlSession); (3) the protection proxy (usually used in the os to control access to critical resouces)
  • template method : constructs the skeleton of the algorithm and leaves the variant part to be implemented by the subclasses
  • adapter : provides a uniform interface to the client which hides the different classes, usually inaccessible to clients
 
 
TO-DO: Open-Close Principle:

Conclusion

Like every principle OCP is only a principle. Making a flexible design involves additional time and effort spent for it and it introduce new level of abstraction increasing the complexity of the code. So this principle should be applied in those area which are most likely to be changed.
 
There are many design patterns that help us to extend code without changing it. For instance the Decorator pattern help us to follow Open Close principle. Also the Factory Method or the Observer pattern might be used to design an application easy to change with minimum changes in the existing code.
 
 

Design Patterns笔记的更多相关文章

  1. [Design Patterns] 3. Software Pattern Overview

    When you're on the way which is unknown and dangerous, just follow your mind and steer the boat. 软件模 ...

  2. Design Patterns Simplified - Part 3 (Simple Factory)【设计模式简述--第三部分(简单工厂)】

    原文链接:http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part3-factory/ Design ...

  3. Design Patterns Simplified - Part 2 (Singleton)【设计模式简述--第二部分(单例模式)】

    原文链接: http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part-2-singleton/ De ...

  4. Head First Design Patterns

    From Head First Design Patterns. Design Principle: Idnetify the aspects of your application that var ...

  5. Apex Design Patterns

    Apex allows you to build just about any custom solution on the Force.com platform. But what are the ...

  6. [Design Patterns] 4. Creation Pattern

    设计模式是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结,使用设计模式的目的是提高代码的可重用性,让代码更容易被他人理解,并保证代码可靠性.它是代码编制真正实现工程化. 四个关键元素 ...

  7. [Design Patterns] 1. Primary concept & term - UML

    It's time to review design patterns, especially when I reach the turning-point of my career. That's ...

  8. 设计模式(Design Patterns)

    设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...

  9. Learning JavaScript Design Patterns The Observer Pattern

    The Observer Pattern The Observer is a design pattern where an object (known as a subject) maintains ...

随机推荐

  1. 来自朝鲜的问候 golang入坑系列

    鸿渐于陆 本想着写满十八式,但按照目前的进度来看,是很难凑够十八式了.所以还是那句话,量力而行,适可而止.能写多少就写多少,我没法保证看完这本golang脱口秀,一定能成为golang大拿.但入了门, ...

  2. 最短路洛谷P2384

    题目背景 狗哥做烂了最短路,突然机智的考了Bosh一道,没想到把Bosh考住了...你能帮Bosh解决吗? 他会给你100000000000000000000000000000000000%10金币w ...

  3. CS Round#53 E Maxor

    题意:给你N个数,你可以从中选出两个数将它们or起来得到M,求M的最大值及得到最大值的方案数. 刚了半个小时得到了一个貌似时O(N log max(Ai)^2)的方法,想了想发现貌似只能做出第一问,但 ...

  4. Javascript实现简单的下拉二级菜单

    在线演示;http://jsfiddle.net/Web_Code/ThhbG/embedded/result/ <span style="font-size:14px;"& ...

  5. jumpserver 堡垒机环境搭建(图文具体解释)

    Jumpserver 是一款由python编写开源的跳板机(堡垒机)系统,实现了跳板机应有的功能.基于ssh协议来管理,客户端无需安装agent. 特点: 全然开源,GPL授权 Python编写.容易 ...

  6. 我理解的malloc()和free()。

    关于malloc和free这两个函数,malloc的使用方法演示样例:int *p=(int *)malloc(2*sizeof(int)); 它表示在堆中开辟一块大小为2*sizeof(int)的一 ...

  7. MySQL数据库使某个不是主键的字段唯一

    在使用MySQL数据的过程中有时候我们须要某个不是主键的字段不反复.这个时候就要用到SQL的UNIQUE约束了. 以下摘抄自w3school里的一段介绍: UNIQUE 约束唯一标识数据库表中的每条记 ...

  8. 《On Writing Well 30th Anniversa》【PDF】下载

    <On Writing Well 30th Anniversa>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382210 内容简 ...

  9. Android开发——使用LitePal开源数据库

    前言:之前使用Android内置的数据库,感觉一大堆SQL语句,一不小心就错了,很难受,学习了这个LItePal的开源数据库,瞬间觉得Android内置的数据库简直是垃圾般的存在 LitePal Gi ...

  10. EditText禁用系统键盘,光标可以继续使用

    在项目中有时候需要使用到自己的键盘,那这个时候就不希望系统键盘在弹出,而且光标还要继续显示,其实一个方法就可以简单实现 /** * 禁止Edittext弹出软件盘,光标依然正常显示. */ publi ...