一些笔记。

  • 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. Lonlife 1000 - Spoon Devil's 3-D Matrix

    1000 - Spoon Devil's 3-D Matrix Time Limit:1s Memory Limit:32MByte Submissions:208Solved:65 DESCRIPT ...

  2. Linux yum安装和源码安装

    转载注明出处:原文地址 Linux Yum 在线安装 在线:Yum配置地址:/etc/yum.repos.d/CentOS-Base.repo 离线:光盘搭建Yum源 挂载光盘 使在线Yum源失效:m ...

  3. oracle中 merge into 的用法

    很多时候我们需要通过筛选条件同时对表进行 更新,插入,删除 等操作.这样如果我们单一的去操作表会显得很麻烦,下面会说到这个merge  into 的用法会极大的优化我们操作表的时间和代码量. 举例,先 ...

  4. keepalived结合nginx实现nginx高可用

    1.简介 Keepalived 是一个基于VRRP协议来实现的LVS服务高可用方案,可以利用其来避免单点故障.一个LVS服务会有2台服务器运行Keepalived,一台为主服务器(MASTER),一台 ...

  5. 大白话Vue源码系列(01):万事开头难

    阅读目录 Vue 的源码目录结构 预备知识 先捡软的捏 Angular 是 Google 亲儿子,React 是 Facebook 小正太,那咱为啥偏偏选择了 Vue 下手,一句话,Vue 是咱见过的 ...

  6. jmeter接口系列:时间戳、加密

    JMeter安装配置 从官网下载JMeter的软件包apache-jmeter-x.x.zip,下载完成之后解压打开jmeter.bat即可. 说明 这里使用的jmeter版本是3.0,jdk版本是j ...

  7. css走过的坑

    css盒模型 1.内联元素 设置宽高无效.margin左右有效上下无效.padding都有效 会被当做字体所以内联之间有间隙 父级元素要设置font-size:0; 内联元素:a.b.button.e ...

  8. Qwt安装(转)

    ======= 安装 ======= Qwt使用qmake编译所有的组件和示例. qmake是Qt发布中的一部分. qmake读取工程文件,工程文件包含了如何工程选项和如何编译特定工程的规则.一个工程 ...

  9. OpenXml读取word内容(二)

    注意事项 上一篇已经说明,这次就不一一说了,直接来正文: word内容 相关代码 方法1 static void Main(string[] args) { string wordPathStr = ...

  10. windows远程桌面连接的时候不显示本地盘符

    近期远程异地pc机部署项目,远程连上后不显示本地盘符,勾选驱动器也无效,试下例如以下方法 在远程主机的文件地址栏里面键入: \\tsclient\D 后面再加入上对应的盘符,你的盘符的名称是什么盘就加 ...