`
d02540315
  • 浏览: 31400 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

Facade vs Proxy

阅读更多
Question:
i feel there is not much difference between a facade and proxy pattern, and they can be exchanged for each other in some cases ., can someone provide light on the diffence in these patterns and when is facade more appropriate to using proxy.
For eg, in my FBN system, the controller talks to another object( facade or proxy or mediator ?) which talks to the data classes ? what is this class between the controller & data classes , proxy or facade ?

Answer1:
A proxy can filter out bad requests, where as a facade doesn't filter anything, it justs acts as a way to make a complex subsystem easier to access for a client.
A proxy is a "Stand-in" it pretends to be the subsystem, taking requests and deciding if it is ok to really send it to the subsystem.
So while they are very much like "Fronts" for an underlying system, there really is two seperate purposes.
I always look at proxies, and think web server proxies to protect web servers for bad people.

Answer2:
Proxies are a stand-in, Facades hide complexity.
Other uses for proxies are accessing remote resources like we are doing and deferring creation of expensive resources until they are actually needed.

Answer3:
A proxy delegates to an instance of the same type as the proxy. A facade not.

Answer4:
“Facade:用于隐藏调用的复杂性”
由于是隐藏复杂性,所以在Facade中就可能包含对后端组件、对象的接口访问,比如来自不同Domain的业务组件、跨专题的技术组件等。简单说,是对后端各接口的聚合,目的为了简化。
“Proxy:保护被访问的对象”
实际上就是控制对后端组件或对象的访问,而且是针对特定组件的访问控制。简单说,是对后端某类特定接口的访问代理


    [Facade]


Facade - 为调用方定义简单的调用接口
Clients - 调用者。通过Facade接口调用提供某功能的内部类群
Packages - 功能提供者。指提供功能的类群(模块或子系统)


    [Proxy]



Subject -被代理的类的接口
Proxy 代理类 - 该代理类实现了Subject接口
RealSubject 代理元 - 即被代理的目标类,它实现了Subject接口

  • 大小: 2.7 KB
  • 大小: 10.8 KB
分享到:
评论

相关推荐

    设计模式1,FACADE模式,Adapter

    设计模式1,FACADE模式,Adapter facade Adapter singleton proxy

    超经典的一部书--设计模式

    Abstract Factory,Builder,Prototype,Singleton ,Adapter_Object,Bridge ...Facade Flyweight Proxy ,Chain of Responsibility Command Iterator Mediator Memento Observer State Strategy Visitor

    Shimterface:创建动态对象facadeproxy的实用程序,以允许将对象用作未明确实现的接口

    鬼脸 用于创建动态对象外观/代理的实用程序,以允许将对象用作未明确实现的接口 描述 我确信我们一直都处于不得不使用外部库(包括mscorlib)中的类的情况,该类要么未实现任何接口,要么未实现可用于以下目的的接口...

    设计模式迷你手册(CHM版)

    创建型 结构型 行为型 类 Factory Method Adapter_Class Interpreter Template Method ...Proxy Chain of Responsibility Command Iterator Mediator Memento Observer State Strategy Visitor

    Learning Python Design Patterns(PACKT,2013)

    Then you will move on to learn about two creational design patterns which are Singleton and Factory, and two structural patterns which are Facade and Proxy. Finally, the book also explains three ...

    设计模式迷你手册.chm

    Facade Flyweight Proxy 行为型 Interpreter Template Method Chain of Responsibility Command Iterator Mediator Memento Observer State Strategy Visitor 内容预览: 名称 Factory Method 结构 ...

    设计模式精解-GoF 23种设计模式解析

    2.6 Facade模式 2.7 Proxy模式 3 行为模式.....55 3.1 Template模式 3.2 Strategy模式 3.3 State模式 3.4 Observer模式 3.5 Memento模式 3.6 Mediator模式 3.7 Command模式 3.8 Visitor模式 3.9 Chain of ...

    23种设计模式的实现(Java 版),java设计模式

    Factory模式,Prototype模式,Builder 模式,Singleton模式,Facade模式,Proxy模式,Adapter模式,Composite模式,Decorator模式....

    Head First Design Patterns 英文原版

    of Design Patterns so that you can hold your own with your co-worker (and impress cocktail party guests) when he casually mentions his stunningly clever use of Command, Facade, Proxy, and Factory in ...

    Head First Design Patterns

    worker (and impress cocktail party guests) when he casually mentions his stunningly clever use of Command, Facade, Proxy, and Factory in between sips of a martini. You'll easily counter with your deep...

    设计模式源码 设计模式例子

    VS2008工程 自己看书时写的例子程序,简单明了,供大家学习参考。 如有不对之处,请多谅解。 AbstractFactory Adapter Bridge chainResponsibility Command Composite Facade Factory Iterator Prototype Proxy

    36种最新设计模式整理

    Design Pattern: Facade 模式 44 Design Pattern: Flyweight 模式 46 Design Pattern: Proxy 模式(一) 48 Design Pattern: Proxy 模式(二) 49 Design Pattern: Chain of Responsibility 模式 53 Design Pattern:...

    精心整理的23种python设计模式代码

    Structural-bridge,Structural-proxy,Structural-composite,Structural-adapter,Structural-flyweightStructural-decorator,Structural-facade,behavioral-visitor,behavioral-strategy,behavioral-memento...

    JAVA 设计模式PPT

    首先介绍了Java中面向对象特性和技术,逐个分析Abstract Factory;Builder;Prototype;Singleton;Adapter (对象);Bridge;Composite;Decorator;Facade;Flyweight;Proxy;Iterator;Observer等模式

    java设计模式教程+源代码

    Facade ( 外观模式 ) Flyweight ( 享元模式 ) Proxy ( 代理模式 ) Chain of Responsibility ( 责任链模式 ) Command ( 命令模式 ) Interpreter ( 解释器模式 ) Iterator ( 迭代器模式 ) Mediator ( 中介者...

    GoF 23种设计模式的详解与应用

    结构模式:设计模式之Facade(外观),设计模式之Proxy(代理),设计模式之Adapter(适配器),设计模式之Composite(组合),设计模式之Decorator(油漆工),设计模式之Bridge,设计模式之Flyweight(享元). 行为模式:设计模式之...

    JAVA设计模式.rar

    代理模式【PROXY PATTERN】 单例模式【SINGLETON PATTERN】  多例模式【MULTITION PATTERN】  工厂方法模式【FACTORY METHOD PATTERN】 抽象工厂模式【ABSTRACT FACTORY PATTERN】 门面模式【FACADE ...

    Java24种设计模式,Java24种设计模式,24种设计模式,学会了这24种设计模式,可以打遍天下无敌手,设计模式非常重要

    2、代理模式PROXY PATTERN 3、单例模式SINGLETON PATTERN 4、多例模式MULTITION PATTERN 5、工厂方法模式FACTORY METHOD PATTERN 6、抽象工厂模式ABSTRACT FACTORY PATTERN 7、门面模式FACADE PATTERN 8、适配器...

    C++设计模式(Design Pattern)范例源代码

    注:项目在 VS2008 下使用。 创建型: 抽象工厂模式(Abstract Factory) 生成器模式(Builder) 工厂方法模式(Factory Method) 原型模式(Prototype) 单件模式(Singleton) 结构型: 适配器模式(Adapter) 桥接模式...

    设计模式源代码

    AbstractFactory Adapter Brige Builder ChainOfResponsibility ...Facade Factory FlyWeight Interpreter Iterator Mediator Memento Observer Prototype Proxy Singleton State Strategy TemplateMethod Visitor

Global site tag (gtag.js) - Google Analytics