What are the differences between proxy, wrapper or a façade classes

前端 未结 3 1130
野的像风
野的像风 2021-01-30 03:05

What are the differences between proxy, wrapper or a façade classes

They all seem to be the same to me, they take an implementation, encapsulate it and then methods are

3条回答
  •  礼貌的吻别
    2021-01-30 03:43

    AFAIK there is not a pattern called wrapper. Seems more like a generic definition of one of the behavioral patterns.

    Facade

    Do not wrap a single class but several. The intent is to make a complex API easier to work with. A .NET example is the WebClient class which uses HttpWebRequest/HttpWebResponse

    Proxy

    Proxies acts as the original object but contains additional logic such as handling a connection or cleaning up resources when done.

    If you are using WCF you can generate a client proxy by supplying the WCF service interface.

    Additional patterns

    There are some more patterns which also is "wrappers":

    • Adapter
    • Decorator

提交回复
热议问题