﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Smile Life-文章分类-Design Pattern</title><link>http://www.blogjava.net/yhw27del/category/8256.html</link><description>Where There is a will There is a way</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 07:55:01 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 07:55:01 GMT</pubDate><ttl>60</ttl><item><title> 基本设计模式</title><link>http://www.blogjava.net/yhw27del/articles/34321.html</link><dc:creator>大头</dc:creator><author>大头</author><pubDate>Wed, 08 Mar 2006 10:22:00 GMT</pubDate><guid>http://www.blogjava.net/yhw27del/articles/34321.html</guid><wfw:comment>http://www.blogjava.net/yhw27del/comments/34321.html</wfw:comment><comments>http://www.blogjava.net/yhw27del/articles/34321.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yhw27del/comments/commentRss/34321.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yhw27del/services/trackbacks/34321.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 整个设计模式贯穿一个原理:&nbsp; <FONT color=#0000ff>面对接口编程，而不是面对实现</FONT>.目标原则是: <FONT color=#0000ff>降低耦合,增强灵活性</FONT>.&nbsp;<SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体><FONT size=2>&nbsp;<BR><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体><FONT size=2><STRONG><BR><FONT size=4><FONT color=#800080>基本的设计模式<SPAN lang=EN-US><o:p></o:p></SPAN></FONT></FONT></STRONG></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体><FONT size=2>&nbsp;<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG><FONT color=#000000><EM>Abstract Factory</EM></FONT></STRONG>：提供一个创建一系列相关或相互依赖对象的接口，而无需指定它们具体的类。（<SPAN>使用得非常频繁。</SPAN>）<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG><FONT color=#000000>Adapter</FONT></STRONG>：将一个类的接口转换成客户希望的另外一个接口。<SPAN lang=EN-US>A d a p t e r模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG><FONT color=#000000>Bridge</FONT></STRONG>：将抽象部分与它的实现部分分离，使它们都可以独立地变化。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG><FONT color=#000000><EM>Builder</EM></FONT></STRONG>：将一个复杂对象的构建与它的表示分离，使得同样的构建过程可以创建不同的表示。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG><FONT color=#000000><EM>Chain of Responsibility</EM></FONT></STRONG>：为解除请求的发送者和接收者之间耦合，而使多个对象都有机会处理这个请求。将这些对象连成一条链，并沿着这条链传递该请求，直到有一个对象处理它。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Command</STRONG>：将一个请求封装为一个对象，从而使你可用不同的请求对客户进行参数化；对请求排队或记录请求日志，以及支持可取消的操作。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Composite</STRONG>：将对象组合成树形结构以表示<SPAN lang=EN-US>“部分-整体”的层次结构。它使得客户对单个对象和复合对象的使用具有一致性。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Decorator</STRONG>：动态地给一个对象添加一些额外的职责。就扩展功能而言， 它比生成子类方式更为灵活。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Facade</STRONG>：为子系统中的一组接口提供一个一致的界面，<SPAN lang=EN-US> F a c a d e模式定义了一个高层接口，这个接口使得这一子系统更加容易使用。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Factory Method</STRONG>：定义一个用于创建对象的接口，让子类决定将哪一个类实例化。<SPAN lang=EN-US>Factory Method使一个类的实例化延迟到其子类。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Flyweight</STRONG>：运用共享技术有效地支持大量细粒度的对象。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Interpreter</STRONG>：给定一个语言<SPAN lang=EN-US>, 定义它的文法的一种表示，并定义一个解释器, 该解释器使用该表示来解释语言中的句子。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Iterator</STRONG>：提供一种方法顺序访问一个聚合对象中各个元素<SPAN lang=EN-US>, 而又不需暴露该对象的内部表示。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Mediator</STRONG>：用一个中介对象来封装一系列的对象交互。中介者使各对象不需要显式地相互引用，从而使其耦合松散，而且可以独立地改变它们之间的交互。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Memento</STRONG>：在不破坏封装性的前提下，捕获一个对象的内部状态，并在该对象之外保存这个状态。这样以后就可将该对象恢复到保存的状态。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Observer</STRONG>：定义对象间的一种一对多的依赖关系<SPAN lang=EN-US>,以便当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并自动刷新。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Prototype</STRONG>：用原型实例指定创建对象的种类，并且通过拷贝这个原型来创建新的对象。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Proxy</STRONG>：为其他对象提供一个代理以控制对这个对象的访问。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Singleton</STRONG>：保证一个类仅有一个实例，并提供一个访问它的全局访问点。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN>State：允许一个对象在其内部状态改变时改变它的行为。对象看起来似乎修改了它所属的类。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Strategy</STRONG>：定义一系列的算法<SPAN lang=EN-US>,把它们一个个封装起来, 并且使它们可相互替换。本模式使得算法的变化可独立于使用它的客户。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体><STRONG>&nbsp;<o:p></o:p></STRONG></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Template Method</STRONG>：定义一个操作中的算法的骨架，而将一些步骤延迟到子类中。<SPAN lang=EN-US>Template Method使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤。<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 新宋体; mso-font-kerning: 0pt"><FONT face=宋体>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=宋体><SPAN><STRONG>Visitor</STRONG>：表示一个作用于某对象结构中的各元素的操作。它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作。</SPAN></FONT></P><img src ="http://www.blogjava.net/yhw27del/aggbug/34321.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yhw27del/" target="_blank">大头</a> 2006-03-08 18:22 <a href="http://www.blogjava.net/yhw27del/articles/34321.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>