Java design mode----appearance mode

Source: Internet
Author: User

The main application scenario of the appearance mode is to provide a simple interface for the complex subsystem and improve the independence of the subsystem.

To create the Drawerone class:

Package Facade;public class Drawerone {public void open () {System.out.println ("first drawer opened"); GetKey ();} public void GetKey () {System.out.println ("Get the key of the first drawer");}}

To create the Drawertwo class:

Package Facade;public class Drawertwo {public void open () {System.out.println ("second drawer opened"); GetFile ();} public void GetFile () {System.out.println ("Get this important file");}}

Observation class:

Package Facade;public class Drawerfacade {drawerone Darwerone = new Drawerone ();D rawertwo darwertwo = new Drawertwo ();p UBL IC void Open () {Darwerone.open ();d arwertwo.open ();}}

Under test, this test class uses the Drawerfacade class uniformly to invoke other subsystem class functions

Package Facade;public class Test {public static void main (string[] args) {Drawerfacade drawer = new Drawerfacade ();d rawer. Open ();}}

Results:

The first drawer was opened to get the key to the first drawer the second drawer was opened to get this important file

Java design mode----appearance 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.