Design Pattern _ Façade mode

Source: Internet
Author: User

Facade Patternprovide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. (Requires that the external communication of a subsystem must be done through a unified object, and that the façade mode provides a high-level interface, making the subsystem easier to use)
Why is this a design pattern?
Public interface Iletterprocess {public void Writercontext (string context), public void Fillenvelope (string address); pub LIC void Letterintoenvelope (); public void Sendletter ();}

public class Letterprocess implements iletterprocess {public void Fillenvelope (String address) {  System.out.println ("Fill in the address of the letter:" +address);} public void Letterintoenvelope () {  System.out.println ("Put the letter in the envelope"), public void Sendletter () {  SYSTEM.OUT.PRINTLN ("postal mail"); } public void Writercontext (String context) {  System.out.println ("Write content:" +context);}}

public class Modenpostoffice {private iletterprocess letterprocess=new letterprocess ();  public void Sendletter (String context,string address) {  This.letterProcess.writerContext (context);  This.letterProcess.fillEnvelope (address);  This.letterProcess.letterIntoEnvelope ();  This.letterProcess.sendLetter (); }}

public class Client {public  static void Main (string[] args) {  modenpostoffice postoffice=new modenpostoffice ();  Postoffice.sendletter ("You were admitted", "xx University");}

Flexible, packaged, secure and less dependent
Shortcomings do not conform to the opening and closing principle, no way to expand
Use scenarios to provide an external access interface subsystem for a complex subsystem or module relative independent prevention of a low level of technical personnel involved in project development, in order to reduce the impact of personal code quality on the overall project risk
I'm a rookie, I'm on my way.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Design Pattern _ Façade mode

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.