一些笔记。

  • 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. codeblocks+mbedtls库配置

    网上都没有找到window下mbedtls的相关配置,或许是太简单了.希望可以帮助那些像我这样的小白一枚. 下载 github的下载:https://github.com/ARMmbed/mbedtl ...

  2. MySQL学习——基本命令(1)

    MySQL添加新用户.为用户创建数据库.为新用户分配权限 参考博客http://blog.csdn.net/u013216667/article/details/70158452 一.登录MySQL ...

  3. mysql优化sql语句的方法

    1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索 ...

  4. centos7 简单搭建lnmp环境

    1:查看环境: 1 2 [root@10-4-14-168 html]# cat /etc/redhat-release CentOS release 6.5 (Final) 2:关掉防火墙 1 [r ...

  5. 使用REST风格架构您需要知道的一些事

    1. REST的由来 2. REST的构成 2.1. 资源 2.2. 资源的表述 2.2.1. MIME(Multipurpose Internet Mail Extensions) 2.2.2. 缓 ...

  6. CSS中line-height与vertical-align

    参考文章: 深入了解CSS的line-height属性 Vertical-Align: 你需要知道的所有事[译] Vertical-Align: All You Need To Know 1.什么是行 ...

  7. iKcamp团队制作|基于Koa2搭建Node.js实战(含视频)☞ 中间件用法

    中间件用法--讲解 Koa2 中间件的用法及如何开发中间件

  8. 【剑指Offer学习】【面试题50:树中两个结点的最低公共祖先】

    题目:求树中两个结点的最低公共祖先,此树不是二叉树,而且没有指向父节点的指针. 树的结点定义 private static class TreeNode { int val; List<Tree ...

  9. Java学习之道:Java操作Excel之导出下载

    页面放置一个button进行点击导出事件 <h:commandLink target="_parent" value="导出"            ac ...

  10. POJ2942 Knights of the Round Table 点双连通分量,逆图,奇圈

    题目链接: poj2942 题意: 有n个人,能够开多场圆桌会议 这n个人中,有m对人有仇视的关系,相互仇视的两人坐在相邻的位置 且每场圆桌会议的人数仅仅能为奇书 问有多少人不能參加 解题思路: 首先 ...