• notice
  • Congratulations on the launch of the Sought Tech site

Appearance Mode

definition

Facade Pattern: Provides a consistent interface for a set of interfaces in a subsystem. This pattern defines a high-level interface that makes the subsystem easier to use.

Structure diagram

write picture description here

specific code

Subsystems:
SubSystemOne class

public class SubSystemOne {    public void methodOne(){
        System.out.println("子系统方法一!");
    }}12345

SubSystemTwo class:

public class SubSystemTwo {    public void methodTwo(){
        System.out.println("子系统方法二!");
    }}12345

SubSystemThree class:

public class SubSystemThree {    public void methodThree(){
        System.out.println("子系统方法三!");
    }}12345

SubSystemFour class:

public class SubSystemFour {    public void methodFour(){
        System.out.println("子系统方法四!");
    }}12345

Appearance class:
It needs to understand the methods of all subsystems and combine them for external calls

public class Facade {    private SubSystemOne one;    private SubSystemTwo two;    private SubSystemThree three;    private SubSystemFour four;
    public Facade(){
        one  = new SubSystemOne();
        two = new SubSystemTwo();
        three = new SubSystemThree();
        four = new SubSystemFour();
    }
    public void methodA(){
        System.out.println("方法组A");
        one.methodOne();
        two.methodTwo();
        four.methodFour();
    }
    public void methodB(){
        System.out.println("方法组B");
        two.methodTwo();
        three.methodThree();
    }}


Tags

Technical otaku

Sought technology together

Related Topic

1 Comments

author

lipitor 20mg cost & lt;a href="https://lipiws.top/"& gt;order atorvastatin 20mg for sale& lt;/a& gt; buy lipitor online cheap

Htzxwv

2024-03-07

Leave a Reply

+