![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
文章平均质量分 68
meran
meran回首,naren却在灯火阑珊处
展开
-
state模式
类图就不画了,和策略模式的差不多。 模式定义 : Allow an object to alter its behavior when its internal state changes。 the object will appear to change its class当原创 2011-07-23 00:43:13 · 308 阅读 · 0 评论 -
Template Method
Template Method 模式 意图 定义一个操作中的算法顾家,将一些步骤推迟到子类中实现。可以不改变算法的结构而重定义该算法的步骤。问题 要完成在某一细节层次一致的一个过程或一系列步骤,但其个别步骤在更详细的层次上实现可能不同 模版模式模版模式 重构中的Form Tem原创 2011-07-15 12:23:39 · 242 阅读 · 0 评论 -
chainOfResponsibility
定义 :Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request .Chain the receivin原创 2011-07-27 15:21:27 · 491 阅读 · 0 评论 -
Composite 模式
定义 :Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and cpmpositio原创 2011-07-29 11:01:32 · 553 阅读 · 0 评论 -
Memento备忘录模式
备忘录模式 备忘录模式(Memento Pattern)又叫做快照模式(Snapshot Pattern)或Token模式,是GoF的23种设计模式之一,属于行为模式。 定义(源于GoF《设计模式》):在不破坏封闭的前提下,捕获一个对象的内部状态,并在该对象原创 2011-07-30 19:31:40 · 519 阅读 · 0 评论 -
Singleton 模式和Double-Checked Locking
意图:保证一个类仅有一个实例,并提供一个访问它的全局方法。 public class Singleton{ private static Single instance; private instance(){}; public static Sing原创 2011-07-16 16:00:25 · 276 阅读 · 0 评论 -
Builder 模式
定义如下:Separate the construction of a complex object from its representation so that the same construction process can different representatio原创 2011-07-18 18:55:01 · 303 阅读 · 0 评论 -
Strategy
首先给出例子 国际电子商务系统:需求各国税率不同,设计一个订单处理系统,包括税率计算,可以用继承来设计, 不同国家对应一个SalesOrder ,但是这样会引起组合爆炸问题,并在代码中引入大量switch语句 所以用Strategy模式来解决问题,根据设计模式的根本原则,面向接原创 2011-07-13 15:36:54 · 300 阅读 · 0 评论 -
Decorator 模式
意图:动态为对象添加职责 例子 package 装饰器;public abstract class Component { void print(){}; }package 装饰器;public abstract class AbstractDecorat原创 2011-07-25 09:20:17 · 291 阅读 · 0 评论 -
中介者模式
定义:Define an object that encapsules how a set of objects interact.Mediator promotes loose couping by keeping objects from refering to each原创 2011-07-25 09:34:23 · 308 阅读 · 0 评论 -
vistor模式
这个访问者模式写的太棒了。。我也就不自己整理了 直接转过来做了标题党=。=这一篇并没有介绍关于访问者模式的进阶,先说一下访问者模式的使用情况,这里引用大话设计模式的例子,因为讲得比较精辟。 假设有男人和女人两种元素,要分别打印出他们在不同状态时的不同表现。 用OO的思想把表现(行转载 2011-07-26 10:55:14 · 5289 阅读 · 0 评论