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.
  • 相关阅读:
    js 平坦化控制流
    js变量名混淆
    ERR_CERT_INVALID
    ERR_CERT_AUTHORITY_INVALID
    @babel/preset-env
    @babel/plugin-transform-runtime
    terminal
    @babel/plugin-proposal-class-properties
    Zotero
    随记 日后整理
  • 原文地址:https://www.cnblogs.com/zhuqiang/p/2468323.html
Copyright © 2011-2022 走看看