![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Thinking in patterns( 阅读笔记)
文章平均质量分 72
ccfangle
这个作者很懒,什么都没留下…
展开
-
1-Classifying patterns
The DesignPatterns book discusses 23 different patterns, classified under three purposes(all of which revolve around the particular aspect that can vary). The threepurposes are: 1. ...原创 2011-12-23 16:05:37 · 122 阅读 · 0 评论 -
15-Composite
Composite模式,有时又叫做部分-整体模式(Part-Whole)。它将对象组织到树结构中,可以用来描述整体与部分的关系。合成模式可以使客户端将单纯元素与复合元素同等看待。 这个模式的具体含义是很好理解的,教材中讲解的还行。具体再参考这个案例一下就更好了!!主要是在具体的实际的中用总结一下!后续...... ...原创 2012-01-12 10:11:40 · 62 阅读 · 0 评论 -
16-Observer
好久之前看过Observer,但是,当时不是很清楚,应该是Java刚刚入门的原因....现在看来啊,是比较优秀、很好的设计模式! Like the otherforms of callback, this contains a hook point where you can change code. Thedifference is in the obser...原创 2012-01-12 21:35:19 · 67 阅读 · 0 评论 -
17-Mediator
Mediator模式:用一个中介对象来封装一系列的对象交互,使各对象不需要显示地相互调用。简单而言就是封装了多个对象之间的复杂操作,使的两个对象解耦! http://www.jdon.com/designpatterns/mediator.htm http://gary0416.iteye.com/blog/913462 ...原创 2012-01-14 19:40:59 · 56 阅读 · 0 评论 -
18-Facade
Facade模式: 为子系统中的一组接口提供一个一致的界面.简言之,就是为凌乱、繁杂的接口(或者是类)构造一个统一的接口(或者是类),便于使用、很多时候达到了复用的目的。这在教材中的例子能够看出来,有一句是很好的总结:A tax adviser is a Façade between you and the tax code, anda mediator between you and...原创 2012-01-15 15:22:17 · 82 阅读 · 0 评论 -
19-Command: choosing the operation at run-time
A Command is a function object in its purest sense: a method that’s an object. By wrapping a method in an object, you can pass it to other methods or objects as a parameter, to tel...原创 2012-02-01 17:45:04 · 67 阅读 · 0 评论 -
20-Chain of responsibility
Chain ofResponsibility might be thought of as a dynamic generalization of recursionusing Strategy objects. You make a call, and each Strategy in alinked sequence tries to satisfy th...原创 2012-02-03 16:25:34 · 92 阅读 · 0 评论 -
21-Memento
Use serialization to create an undo mechanism.这是教材中唯一一句讲解!正如Memento(纪念物)的含义提示一样,该设计模式有记忆效果,能恢复原状态!准确来说就是:在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将该对象恢复到原先保存的状态。 该设计模式实际...原创 2012-02-03 17:57:05 · 149 阅读 · 0 评论 -
22-Visitor
The assumption is that you have a primary class hierarchy that is fixed; perhaps it’s from another vendor and you can’t make changes to that hierarchy. However, you’d like to add new polym...原创 2012-02-05 11:12:43 · 67 阅读 · 0 评论 -
23-Interpreter
If theapplication user needs greater run time flexibility, for example to createscripts describing the desired behavior of the system, you can use the Interpreterdesign pattern. Here, you c...原创 2012-02-05 14:51:52 · 68 阅读 · 0 评论 -
24-Prototype
Prototype(原型模式):用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。 该模式允许一个对象再创建另外一个可定制的对象,根本无需知道任何如何创建的细节,工作原理是:通过将一个原型对象传给那个要发动创建的对象,这个要发动创建的对象通过请求原型对象拷贝它们自己来实施创建。由于Java提供clone()方法来实现对象的克隆,所以Prototype模式实...原创 2012-02-06 14:56:26 · 86 阅读 · 0 评论 -
14-Bridge
思考了好一阵,总是没有一个合适的答案,感觉没有办法继续往下写了.... 先展示一下Bridge设计模式的目的就是:将抽象与其实现解耦,使它们可以独立的适应变化,这是在Gof中的描述(很是通用,但是没有感觉....) 老实说,教材中的例子比较抽象啊,不是很容易理解,但是讲解还算可以,毕竟是外文啊,参考了一些博客内容,感觉这个讲解比较集中,好理解。 ...原创 2012-01-11 17:06:42 · 88 阅读 · 0 评论 -
13-Adapter
接下来的两个模式目的就是:Connecting different typesAdapter takes one type and produces an interface tosome other type. When you’ve got this,and you need that, Adapter solves the problem. The only...原创 2012-01-10 21:38:58 · 68 阅读 · 0 评论 -
12-Decorator:too many classes
呵,从翻译这个标题开始这个模式学习吧:The use of layered objects to dynamically and transparently addresponsibilities to individual objects is referred to as the decoratorpattern.--利用多层对象动态、透明地给一个对象添...原创 2012-01-06 20:17:40 · 436 阅读 · 0 评论 -
3-Proxy: fronting for another object
java动态代理(JDK和cglib) JAVA的动态代理 代理模式 代理模式是常用的java设计模式,他的特征是代理类与委托类有同样的接口,代理类主要负责为委托类预处理消息、过滤消息、把消息转发给委托类,以及事后处理消息等。代理类与委托类之间通常会存在关联关系,一个代理类的对象与一个委托类的对象关联,代理类的对象本身并不真正实现服务,而是通过调用委托类的对...原创 2011-12-26 11:03:45 · 94 阅读 · 0 评论 -
2-Singleton
基本概念Singleton是一种创建性模型,它用来确保只产生一个实例,并提供一个访问它的全局访问点.对一些类来说,保证只有一个实例是很重要的,比如有的时候,数据库连接或Socket连接要受到一定的限制,必须保持同一时间只能有一个连接的存在.再举个例子,集合中的set中不能包含重复的元素,添加到set里的对象必须是唯一的,如果重复的值添加到set,它只...原创 2011-12-26 11:12:53 · 101 阅读 · 0 评论 -
4-State: changing object behavior
An object that appears to change its class.Indications: conditional code in most or all methods.The Statepattern switches from one implementation to another during the lifetime of thesurrogate...原创 2011-12-26 21:50:59 · 80 阅读 · 0 评论 -
5-Iterators: decoupling algorithms from containers
In the process,he realized that iterators are central to the use of algorithms, because they decouplethe algorithms from the specific type of containe...只看这个,不是很好理解。找了两个资料,感觉是比较好的例子:<1>...原创 2011-12-27 15:39:44 · 73 阅读 · 0 评论 -
6-Strategy: choosing the algorithm at run-time
Strategy: choosing thealgorithm at run-timeStrategyalso adds a “Context” which can be a surrogate class that controls theselection and use of the particular strategy object—just like Sta...原创 2011-12-29 10:40:15 · 142 阅读 · 0 评论 -
7-Policy: generalized strategy
Although GoF says that Policy is just another name forstrategy, their use of Strategy implicitly assumes a single method in thestrategy object – that you’ve broken out your changing algorithm as a...原创 2012-01-01 15:58:57 · 125 阅读 · 0 评论 -
8-Template method
An applicationframework allows you to inherit from a class or set of classes and create a newapplication, reusing most of the code in the existing classes and overridingone or more methods in or...原创 2012-01-01 20:50:34 · 92 阅读 · 0 评论 -
9-Factory method(Simple Factory method&Abstract factories)
//工厂方法的理解比较容易,重要还是如何在实践中应用。以下范例比较经典: 基本概念 FactoryMethod是一种创建性模式,它定义了一个创建对象的接口,但是却让子类来决定具体实例化哪一个类.当一个类无法预料要创建哪种类的对象或是一个类需要由子类来指定创建的对象时我们就需要用到FactoryMethod 模式了.简单说来,FactoryMethod可...原创 2012-01-03 19:16:47 · 82 阅读 · 0 评论 -
10-Builder
The goal of builder is to separate the construction from the“representation,” to allow multiple different representations. The constructionprocess stays the same, but the resulting object has di...原创 2012-01-06 09:14:23 · 77 阅读 · 0 评论 -
11-Flyweight: too many objects
The odd thing about flyweight, in the company of the otherdesign patterns, is that it’s a performance hack. It’s generally ideal tosimply make an object for every item in your system, but some pro...原创 2012-01-06 16:10:52 · 145 阅读 · 0 评论 -
25-设计模式学习总结
在学习Thinking in patterns之前,我认真学习了Thinking in Java。承前启后的学习,让我对OO有了更近一步的认识, 继承、多态等面向对象的概念,不是仅仅了解概念就OK。一些深层次的知识是需要在实际操作后才能真正明白,很多知不是简单样例讲解能够代表的,最主要的是自己在实际项目参与时,或者在平时的开源代码学习、应用中,将编程思想贯彻进去,这才是软件开...原创 2012-02-06 15:42:40 · 83 阅读 · 0 评论