JAVA design mode: Facade)

Source: Internet
Author: User

The appearance mode provides a consistent interface for a group of interfaces in the subsystem. The Facade mode defines a high-level interface, which makes this subsystem easier to use.

There are many examples of the appearance of security system applications on the Internet. Here I will give an example of a customer service center. Customer Complaints are generally handled through the following series of operations: register the complaint information, assign the Department to be accepted, and submit the complaint information.

If there is no customer service MM, the customer needs to perform registration information, allocate a department, and submit a complaint. I believe you will go crazy soon.

 

With a customer service MM, the user directly deals with the customer service, and the customer service MM completes subsequent operations for us.

In the above example, the role of the Service MM is the Facade defined in the appearance mode (also known as "Facade "). For a series of complex operations (that is, sub-applications in the Program), users do not care about the details of these operations. In this case, we need to provide an entrance for unified access to these complex operations. All operations on each sub-application are completed through this portal. for users, you only need to care about the functions provided by this portal.

The appearance mode mainly focuses on two aspects: first, All accesses to sub-applications must be completed through a unified portal, and second, this portal is only used to access complex operations in sub-applications, other business logic cannot be added.

The above example of customer service MM is implemented using the appearance mode. The Code is as follows:

[Java]
Class OperationRegist {
Void regist (){
// Handle complaint registration
}
}
 
Class OperationDispatch {
Void dispatch (){
// Handle complaint allocation
}
}
 
Class OperationSubmit {
Void submit (){
// Submit Complaint Handling
}
}
 
Class OperationFacade {
OperationRegist op1 = new OperationRegist ();
OperationDispatch op2 = new OperationDispatch ();
OperationSubmit op3 = new OperationSubmit ();

Void operate (){
Op1.regist ();
Op2.dispatch ();
Op3.submit ();
}
}
By fancy888

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.