??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品亚洲综合天堂夜夜,日韩亚洲人成网站,亚洲日本va在线视频观看http://www.tkk7.com/EvanLiu/category/29139.html休息Q休?/description>zh-cnThu, 17 Sep 2009 16:53:32 GMTThu, 17 Sep 2009 16:53:32 GMT60Bridge模式http://www.tkk7.com/EvanLiu/archive/2008/02/01/178856.htmlEvanLiuEvanLiuFri, 01 Feb 2008 08:20:00 GMThttp://www.tkk7.com/EvanLiu/archive/2008/02/01/178856.htmlhttp://www.tkk7.com/EvanLiu/comments/178856.htmlhttp://www.tkk7.com/EvanLiu/archive/2008/02/01/178856.html#Feedback0http://www.tkk7.com/EvanLiu/comments/commentRss/178856.htmlhttp://www.tkk7.com/EvanLiu/services/trackbacks/178856.html7、BRIDGE—早上碰到MMQ要说早上好Q晚上碰到MMQ要说晚上好Q碰到MMI了件新服Q要说你的服好漂亮哦,到MM新做的发型,要说你的头发好漂亮哦。不要问?#8220;早上到MM新做了个发型怎么?#8221;q种问题Q自qBRIDGEl合一下不p?br />
【GOF95】在提出桥梁模式的时候指出,桥梁模式的用意是"抽象化(Abstraction)与实现化(Implementation)p,使得二者可以独立地变化"。这句话有三个关键词Q也是抽象化、实现化和脱耦?/span>



/**
 * 抽象化角?br />  */
public abstract class Abstraction {
    protected Implementor imp;    
    public void setImp(Implementor imp) {
        this.imp = imp;
    }
    public void operation() {
        imp.operationImpl();
    }
}
/**
 * 修正抽象化角色A
 */
public class RefinedAbstractionA extends Abstraction {
    public void operation() {
        //improved logic
    }
}
/**
 * 修正抽象化角色B
 */
public class RefinedAbstractionB extends Abstraction {
    public void operation() {
        //improved logic
    }
}
/**
 * 实现化角?br />  */
public abstract class Implementor {
    public abstract void operationImp();
}
/**
 * 具体实现化角色A
 */
public class ConcreteImplementorA extends Implementor {
    public void operationImp() {
        System.out.println("Do something...");
    }
}
/**
 * 具体实现化角色B
 */
public class ConcreteImplementorB extends Implementor {
    public void operationImp() {
        System.out.println("Do another thing...");
    }
}
public class Client {
    public static void main(String[] args) {
        Abstraction abs = new RefinedAbstractionA();
        abs.setImp(new ConcreteImplementorA());  //{于把RefinedAbstractionA和ConcreteImplementorAl合h?br />         abs.operation();
        abs.setImp(new ConcreteImplementorB());  //{于把RefinedAbstractionA和ConcreteImplementorBl合h?br />         abs.operation();
        
        //或者再换RefinedAbstractionB
        //...
    }
}


EvanLiu 2008-02-01 16:20 发表评论
]]>
Adapter模式http://www.tkk7.com/EvanLiu/archive/2008/01/31/178673.htmlEvanLiuEvanLiuThu, 31 Jan 2008 06:28:00 GMThttp://www.tkk7.com/EvanLiu/archive/2008/01/31/178673.htmlhttp://www.tkk7.com/EvanLiu/comments/178673.htmlhttp://www.tkk7.com/EvanLiu/archive/2008/01/31/178673.html#Feedback0http://www.tkk7.com/EvanLiu/comments/commentRss/178673.htmlhttp://www.tkk7.com/EvanLiu/services/trackbacks/178673.htmlADAPTER —在朋友聚会上碰C一个美女SarahQ从香港来的Q可我不会说_语Q她不会说普通话Q只好求助于我的朋友kent了,他作为我和Sarah之间的AdapterQ让我和Sarah可以怺交谈?也不知道他会不会耍我)

个h理解Q适配器模式,是两个水管A(Target)和C(Adaptee)接口不匹配不兼容Q就拿另外一截管子B(Adapter)Q一头接上原本的水管AQ承)Q另一头接上C(调用)。那么,A通过BQ和C接上了?br />
public interface Target {
    public void methodA();
}
public class Adaptee {
    public void methodB() {
       //do something...
    }
}
public class Adapter extends Target {
    private Adaptee ee;
    public Adapter(Adaptee ee) {
       this.ee = ee;
    }
    public void methodA() {  //水管C Adapter的接?br />        ee.methodB();  //实际调用了水B Adaptee的接?br />     }
}

Adapter和Proxy的区别:
adapter是适配adaptee和target之间的关p?wbr>Qproxy是realSubject对subject的代理?br /> adaptee和target无关p,realSubject和subject有承关pR这是他们的区别?/span>

q里有篇文章很不错,链接一下:
http://yichao.blog.edu.cn/user2/yichaozhang/archives/2006/1501606.shtml

又找到网上另一个见解:
proxy 和adapter有一定类|都是属于一U衔接性质的?br /> 区别是很明显的,从大体上_proxy是一U原来对象的代表Q其它需要与q个对象打交道的操作都是和这个代表交涉,p歌星的经Uh一栗?br /> adapter目的则不是要虚构Z个代表者,而是为应付特定用目的,原来的c进行一些组合?/span>






EvanLiu 2008-01-31 14:28 发表评论
]]>
Command模式http://www.tkk7.com/EvanLiu/archive/2008/01/24/177539.htmlEvanLiuEvanLiuThu, 24 Jan 2008 08:45:00 GMThttp://www.tkk7.com/EvanLiu/archive/2008/01/24/177539.htmlhttp://www.tkk7.com/EvanLiu/comments/177539.htmlhttp://www.tkk7.com/EvanLiu/archive/2008/01/24/177539.html#Feedback0http://www.tkk7.com/EvanLiu/comments/commentRss/177539.htmlhttp://www.tkk7.com/EvanLiu/services/trackbacks/177539.html

14、COMMAND—俺有一个MM安得特别严,没法见面Q只好借助于她弟弟在我们俩之间传送信息,她对我有什么指C,写一张纸条让她弟弟带l我?br /> q不Q她弟弟又传送过来一个COMMANDQؓ了感谢他Q我请他吃了杂酱面Q哪知道他说Q?我同时给我姐姐三个男朋友送COMMANDQ就C最气Q才h吃面?Q?-(

命o模式Q命令模式把一个请求或者操作封装到一个对象中。命令模式把发出命o的责d执行命o的责d割开Q委z不同的对象?br /> 命o模式允许h的一方和发送的一方独立开来,使得h的一方不必知道接收请求的一方的接口Q更不必知道h是怎么被接Ӟ以及操作是否执行Q?br /> 何时被执行以及是怎么被执行的。系l支持命令的撤消?/p>

 

 



典型的Command模式需要有一个接?接口中有一个统一的方?q就?命?h装为对?:
public interface Command {
    public abstract void execute ( );
}


《Java与模式》一书中的例子如下:
/**
 * 客户?Client)代码
 */
public class Client {
    public static void main(String[] args) {
        Receiver receiver = new Receiver();
        Command command = new ConcreteCommand(receiver);
        Invoker invoker = new Invoker(command);
        invoker.action();
    }
}
/**
 * h?Invoker)角色代码
 */
public class Invoker {
    private Command command;
    public Invoker(Command command) {
        this.command = command;
    }
    public void action() {
        command.execute();
    }
}
/**
 * 接收?Receiver)角色代码
 */
public class Receiver {
    public Receiver() {
        //write code here
    }
    public void action() {
        System.out.println(""Action has been taken);
    }
}
/**
 * 抽象命o角色由Command接口扮演
 */
public class Command {
    void execute();
}
/**
 * 具体命oc?br />  */
public class ConcreteCommand implements Command {
    private Receiver receiver;
    public ConcreteCommand(Receiver receiver) {
        this.receiver = receiver;
    }
    public void execute() {
        receiver.action();
    }
}


再用某公司写的Command模式Q简化代码写个大概样子:
/**
 * 客户?Client)代码
 */
public class Client {
    public static void main(String[] args) {
        String receiverName = "xAO";
        String methodName = "methodA";
        
        //receiverNameq里用Spring的依赖注入来创徏Receiver对象
        Command command = new ConcreteCommand(receiverName);
        command.getParameters.put("method", methodName);   //实际代码做了装Qƈ不是q样直接写的。这里简化一?br />         command.getParameters.put("param1", "param1"); //传递参?br />         command.getParameters.put("param2", "param2");
        
        Result result = getNewInvoker.execute(command); //创徏Invoker对象Qƈ调用receiver执行最l的Ҏ
    }
}
/**
 * h?Invoker)角色代码
 */
public class Invoker {
    private Command command;
    public Invoker(Command command) {
        this.command = command;
    }
    public void action() {
        command.execute();
    }
    
    private BeanFactoryService  beanFactory;
    
    public Result execute(Command command) {
        ApplicationObject ao = beanFactory.getBean(command.getName(), ApplicationObject.class, new XXProcessor(command));
        return ao.execute();  //q里是接收者Receiver来执行具体方?
xAO.methodA();
    }
}

/**
 * 抽象命o角色由Command接口扮演
 */
public class Command {
    //...
    //没有execute()Ҏ
}
/**
 * 具体命oc?br />  */
public class ConcreteCommand implements Command {
    //也没有execute()Ҏ
    //...
}






EvanLiu 2008-01-24 16:45 发表评论
]]>
Proxy模式http://www.tkk7.com/EvanLiu/archive/2008/01/24/177479.htmlEvanLiuEvanLiuThu, 24 Jan 2008 05:48:00 GMThttp://www.tkk7.com/EvanLiu/archive/2008/01/24/177479.htmlhttp://www.tkk7.com/EvanLiu/comments/177479.htmlhttp://www.tkk7.com/EvanLiu/archive/2008/01/24/177479.html#Feedback0http://www.tkk7.com/EvanLiu/comments/commentRss/177479.htmlhttp://www.tkk7.com/EvanLiu/services/trackbacks/177479.html12、PROXY?跟MM在网上聊天,一开头L“hi,你好”,“你从哪儿来呀Q?#8221;“你多大了Q?#8221;“w高多少呀Q?#8221;q些话,真烦人,写个E序做ؓ我的Proxy吧,凡是接收到这些话都设|好了自动的回答Q接收到其他的话时再通知我回{,怎么P酷吧?/span>

代理模式Q代理模式给某一个对象提供一个代理对象,q由代理对象控制Ҏ对象的引用。代理就是一个h或一个机构代表另一个h或者一个机构采取行动。某些情况下Q客户不x者不能够直接引用一个对象,代理对象可以在客户和目标对象直接起到中介的作用。客L分L不出代理主题对象与真实主题对象。代理模式可以ƈ不知道真正的被代理对象,而仅仅持有一个被代理对象的接口,q时候代理对象不能够创徏被代理对象,被代理对象必Lpȝ的其他角色代为创建ƈ传入?/span>

public interface Subject {
    public void methodA();
}
public class RealSubject implements Subject {
    public void methodA() {
       System.out.println("...");
    }
}
public class Proxy implements Subject {
    private RealSubject r;
    public void methodA() {
       if(r == null) {
          r = RealSubject();
       }
       r.methodA();
       //do something...
    }
}
我觉得可以理解ؓ通过RealSubject的兄弟Proxy去调用RealSubject的方?br />
和Decorator模式的比较:
相同点:Both patterns use a proxy that forwards method calls to another object, known as the real subject.
不同点:with the Proxy pattern, the relationship between a proxy and the real subject is typically set at compile time, whereas  decorators can be recursively constructed at runtime.
从另一U角度考虑Q?/span>proxy是对cȝ代理Q强调的是对已有功能的代理;而decorator更多的是用于增加装饰Q来丰富cȝ内涵?/span>


Adapter和Proxy的区别:
adapter是适配adaptee和target之间的关p?wbr>Qproxy是realSubject对subject的代理?br /> adaptee和target无关p,realSubject和subject有承关pR这是他们的区别?/span>

q里有篇文章很不错,链接一下:
http://yichao.blog.edu.cn/user2/yichaozhang/archives/2006/1501606.shtml

又找到网上另一个见解:
proxy 和adapter有一定类|都是属于一U衔接性质的?br /> 区别是很明显的,从大体上_proxy是一U原来对象的代表Q其它需要与q个对象打交道的操作都是和这个代表交涉,p歌星的经Uh一栗?br /> adapter目的则不是要虚构Z个代表者,而是为应付特定用目的,原来的c进行一些组合?/span>



EvanLiu 2008-01-24 13:48 发表评论
]]>
Decorator/Wrapper模式http://www.tkk7.com/EvanLiu/archive/2008/01/24/177450.htmlEvanLiuEvanLiuThu, 24 Jan 2008 03:31:00 GMThttp://www.tkk7.com/EvanLiu/archive/2008/01/24/177450.htmlhttp://www.tkk7.com/EvanLiu/comments/177450.htmlhttp://www.tkk7.com/EvanLiu/archive/2008/01/24/177450.html#Feedback0http://www.tkk7.com/EvanLiu/comments/commentRss/177450.htmlhttp://www.tkk7.com/EvanLiu/services/trackbacks/177450.html9?DECORATOR: Maryq完轮到Sarlyq生日,q是不要叫她自己挑了Q不然这个月伙食费肯定玩完,拿出我去q在华山上照的照片Q在背面写上 “最好的的礼物,是׃的Fita”Q再到街上礼品店C个像框(卖礼品的MM也很漂亮哦)Q再N壁搞术设计的Mike设计了一个漂亮的盒子装v?#8230;…Q我们都是DecoratorQ最l都在修饰我q个人呀Q怎么P看懂了吗Q?/span>

装饰模式Q装饰模式以对客L透明的方式扩展对象的功能Q是l承关系的一个替代方案,提供比承更多的灉|性。动态给一个对象增加功能,q些功能可以再动态的撤消。增加由一些基本功能的排列l合而生的非常大量的功能?/span>


它最l典的特征就是:

1.
必须有一?span style="color: red;">它自q父类?span style="color: red;">自己的成员变量;
2.必须l承公共父类?br />

public interface Component {
    public void methodA();
}
public class ConcreteComponent implements Component {
    public void methodA() {
       //do somthing...
    }
}
public class Decorator implements Component {
    private Component c;
   
    public Decorator(Component c) {
       this.c = c;
    }
    public void methodA() {
       //do sth.
       c.methodA();
       //do sth.
    }
}

下面q个例子来自Head FirstQ收?br /> http://www.tkk7.com/sterning/archive/2008/01/21/176679.html


EvanLiu 2008-01-24 11:31 发表评论
]]>
观察者模式(ObserverQ?/title><link>http://www.tkk7.com/EvanLiu/archive/2007/11/12/160018.html</link><dc:creator>EvanLiu</dc:creator><author>EvanLiu</author><pubDate>Mon, 12 Nov 2007 09:44:00 GMT</pubDate><guid>http://www.tkk7.com/EvanLiu/archive/2007/11/12/160018.html</guid><wfw:comment>http://www.tkk7.com/EvanLiu/comments/160018.html</wfw:comment><comments>http://www.tkk7.com/EvanLiu/archive/2007/11/12/160018.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/EvanLiu/comments/commentRss/160018.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/EvanLiu/services/trackbacks/160018.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: 宋体;"><strong><span style="color: blue;">19</span></strong></span><strong><span style="font-size: 10pt; color: blue; font-family: 宋体;">、OBSERVER</span></strong><span style="font-size: 10pt; font-family: 宋体;"> ?/span><span style="font-size: 10pt; font-family: 宋体;">想知道咱们公司最新MM情报吗?加入公司的MM情报邮gl就行了Qtom负责搜集情报Q他发现的新情报不用一个一个通知我们Q直接发布给邮gl,我们作ؓ订阅者(观察者)可以及时收到情报啦 </span><span style="font-size: 10pt; font-family: 宋体;"><br /> <br /> </span><strong><span style="font-size: 10pt; font-family: 宋体;">观察者模?/span></strong><span style="font-size: 10pt; font-family: 宋体;">Q观察者模式定义了一U一队多的依赖关p,让多个观察者对象同时监听某一个主题对象。这个主题对象在状态上发生变化Ӟ会通知所有观察者对象,使他们能够自动更新自己?br /> <br /> </span><br /> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><font size="3"><span style="font-family: 宋体;">观察者(</span><font face="Times New Roman">Observer</font><span style="font-family: 宋体;">Q模式又名发?/span><font face="Times New Roman">-</font><span style="font-family: 宋体;">订阅Q?/span><font face="Times New Roman">Publish/Subscribe</font><span style="font-family: 宋体;">Q模式?/span><font face="Times New Roman">GOF</font><span style="font-family: 宋体;">l观察者模式如下定义:定义对象间的一U一对多的依赖关p,当一个对象的状态发生改变时Q所有依赖于它的对象都得到通知q被自动更新?/span></font></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><font size="3"><span style="font-family: 宋体;">观察者模式的l成部分?/span></font></p> <p style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt;"><font face="Times New Roman"><font size="3">1)</font><span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">        </span></font><font size="3"><span style="font-family: 宋体;">抽象目标角色Q?/span><font face="Times New Roman">Subject</font><span style="font-family: 宋体;">Q?/span></font></p> <p style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt;"><font face="Times New Roman"><font size="3">2)</font><span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">        </span></font><font size="3"><span style="font-family: 宋体;">抽象观察者角Ԍ</span><font face="Times New Roman">Observer</font><span style="font-family: 宋体;">Q?/span></font></p> <p style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt;"><font face="Times New Roman"><font size="3">3)</font><span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">        </span></font><font size="3"><span style="font-family: 宋体;">具体目标角色Q?/span><font face="Times New Roman">Concrete Subject</font><span style="font-family: 宋体;">Q?/span></font></p> <p style="margin: 0cm 0cm 0pt 42pt; text-indent: -21pt;"><font face="Times New Roman"><font size="3">4)</font><span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">        </span></font><font size="3"><span style="font-family: 宋体;">具体观察者角Ԍ</span><font face="Times New Roman">Concrete Observer</font><span style="font-family: 宋体;">Q?/span></font></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><br /> <font size="3"></font></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><br /> <font size="3"></font></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><font size="3"><span style="font-family: 宋体;"><br /> </span></font></p> <br /> <span style="font-size: 10pt; font-family: 宋体;"><br /> </span><br /> <!-- q告?--> <script type="text/JavaScript"> alimama_pid="mm_10891533_910884_1874773"; alimama_titlecolor="0000FF"; alimama_descolor ="000000"; alimama_bgcolor="FFFFFF"; alimama_bordercolor="E6E6E6"; alimama_linkcolor="008000"; alimama_bottomcolor="FFFFFF"; alimama_anglesize="0"; alimama_bgpic="0"; alimama_icon="0"; alimama_sizecode="15"; alimama_width=950; alimama_height=90; alimama_type=2; </script> <script src="http://a.alimama.cn/inf.js" type=text/javascript> </script> <img src ="http://www.tkk7.com/EvanLiu/aggbug/160018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/EvanLiu/" target="_blank">EvanLiu</a> 2007-11-12 17:44 <a href="http://www.tkk7.com/EvanLiu/archive/2007/11/12/160018.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> վ֩ģ壺 <a href="http://57798b.com" target="_blank">ھƵƷ </a>| <a href="http://caobi97.com" target="_blank">һƬѿ</a>| <a href="http://lh726.com" target="_blank">ھƷ߹ۿ</a>| <a href="http://tsxyhq.com" target="_blank">AVһδ </a>| <a href="http://327www.com" target="_blank">Ƭ߹ۿ</a>| <a href="http://www-kj5799.com" target="_blank">GVGVͬ</a>| <a href="http://adcacs.com" target="_blank">޾ƷһۺϾƷ </a>| <a href="http://dqcjlb.com" target="_blank">2022ѹƷ</a>| <a href="http://583s.com" target="_blank">һƬ߲</a>| <a href="http://jlzjjy.com" target="_blank">޾ñĻ</a>| <a href="http://snsdtv.com" target="_blank">Ʒһ߲</a>| <a href="http://69xjj.com" target="_blank">պëƬ</a>| <a href="http://tom-erc20.com" target="_blank">xxxxxƵ</a>| <a href="http://mallmirror.com" target="_blank">һƵ߹ۿwww </a>| <a href="http://sdtuoliuta.com" target="_blank">91۲ѹ</a>| <a href="http://www66913.com" target="_blank">ƷƵһ</a>| <a href="http://niu44.com" target="_blank">ϼ߿</a>| <a href="http://kencery.com" target="_blank">ɫվwwwͬ</a>| <a href="http://zbhongtai.com" target="_blank">þ޹ƷAVϼ</a>| <a href="http://tsj68.com" target="_blank">þþþþaŷa</a>| <a href="http://amjt9.com" target="_blank">ëbbw</a>| <a href="http://wwwkckc.com" target="_blank">޹뾫ƷŮ˾þþò</a>| <a href="http://hylaowu.com" target="_blank">99ƷȫѹۿƵ</a>| <a href="http://jiucaoji.com" target="_blank">鶹Ƶѹۿ</a>| <a href="http://3x79.com" target="_blank">߿վ</a>| <a href="http://gzmcmy.com" target="_blank">þ99Ʒѿ</a>| <a href="http://0755host.com" target="_blank">ҹѿƬڵ</a>| <a href="http://ydstbj.com" target="_blank">ƷžƷƵ</a>| <a href="http://sczxzt.com" target="_blank">عΰAëƬѿ</a>| <a href="http://www-75044.com" target="_blank">ŷxƵ</a>| <a href="http://lfhuanxin.com" target="_blank">޳avƬ롿</a>| <a href="http://yuejiju.com" target="_blank">91ۺ</a>| <a href="http://pc521.com" target="_blank">һһ</a>| <a href="http://youkabaitiao.com" target="_blank">޳aƬ߹ۿƷ</a>| <a href="http://hysw100.com" target="_blank">2020ˬ</a>| <a href="http://hcdigi.com" target="_blank">һƵ</a>| <a href="http://otkaxap.com" target="_blank">¹޾ƷӰԺ</a>| <a href="http://zjlxblog.com" target="_blank">99999þþþþ</a>| <a href="http://ziniurj.com" target="_blank">ɫվWWWվ</a>| <a href="http://smalody.com" target="_blank">337Pձŷ޴ͼ</a>| <a href="http://nsmtv.com" target="_blank">gayˬˬƵ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>