10. facade (appearance, facade)

Source: Internet
Author: User

Facade (appearance, facade)

An external user object interacts with a sub-system through a uniform facade object. The facade mode is a set of interfaces in the subsystem, providing a uniform facade for external objects to access. That is, the facade mode defines a higher level interface for external objects to use this subsystem easily.

 

Applicability:

1. You want to provide simple interfaces for a complex subsystem.

2. CustomerProgramThere is a large degree of dependency between the implementation part of the abstract class.

3. When you need to build a layered sub-system, use the facade mode to define each previous entry in the sub-system. If subsystems are mutually dependent, you can allow them to communicate only through facade, thus simplifying the dependency between them.

4. In the distributed system, to reduce the number of remote calls by the client, the facade mode is used to effectively reduce remote calls.

 

Structure:

1. facade (cfacade): the facade object is a coordinator who knows that the sub-system class needs the corresponding requests to implement those functions. He is responsible for entrusting client requests to appropriate subsystem objects.

2. subsystem (csubsystem): it is responsible for implementing the functions of the subsystem. It can be called either by a facade object or by a client directly. They do not know the facade object and do not need to maintain the reference with the facade object.

 

When working in the facade mode, the client that uses the facade object does not need to directly access the subsystem object. Instead, the facade object transmits the client request to the appropriate subsystem object, allowing the subsystem object to complete the actual work. This means that the facade object calls the method of the relevant subsystem and converts the subsystem interface to the interface required by the client. It turns out that the client needs to deal with multiple subsystems, and now it becomes a client that only deals with one facade object. This reduces the dependency and complexity between systems.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.