zoukankan      html  css  js  c++  java
  • Head First Design Patterns Facade Pattern

    The Facade Pattern provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

    A facade not only simplifies an interface, it decouples a client from a subsystem of components.

    Facades and adapters may wrap multiple classes, but a facade's intent is to simplify, while an 

    adapter's is to convert the interface to something different.

    The principle of least knowledge - talk only to your immediate friends.

    the principle tell us that we should only invoke methods that belong to:

    • The object itself
    • Objects passed in as a parameter to the method.
    • Any objects the method creates or instantiates
    • Any components of the object

    Summarize:

    • when you need to use an existing class and its interface is not the one you need, use an adapter
    • when you need to simplify and unify a large interface or complex set of interfaces, use a facade.
    • An adapter changes an interface into one a client expects.
    • A facade decouples a client from a complex subsytem.
    • Implementing an adapter may require little work or a great deal of work depending on the size and complexity  of  the     target  interface.
    • Implementing a facade requires that we compose the facade with its subsystem and usedelegation to perform the work   of the facade.
  • 相关阅读:
    使用c#读取/解析二维码
    MVVM中的RelayCommand与AsyncCommand
    MVVM模式下的OpenFileDialog
    集成Source Monitor至VS中
    [转]异步command的实现
    使用Messenger实现MVVM的对话框弹出
    使用NPOI访问、控制Excel
    win11更新
    Codeforces Round #749 总结
    Codeforces Round #697 (Div. 3)
  • 原文地址:https://www.cnblogs.com/zhuqiang/p/2468323.html
Copyright © 2011-2022 走看看