代理模式与装饰器模式的区别
时间:2014-05-01 18:47:25
收藏:0
阅读:354
代理模式与装饰器模式的区别,主要大于,从使用者(客户端)的角度来看的:
//装饰器的客户
public class Client{
public static void main(String[] args){
//客户指定了装饰者需要装饰的是哪一个类
Component component = new Decorator(new ConcreteComponent());
…
}
}
//代理的客户
public class Client{
public static void main(String[] args){
//客户不知道代理委托了另一个对象
Subject subject = new Proxy();
…
}
}
评论(0)