Facade Pattern

Controls the use of many Facade classes. user uses classes under Facade through Facade </ font>

Design Pattarm MENU

Check with the following class structure

package Access modifier class Explanation
sample public facade.class Control the calling and usage of each class managed by facade
sample default sam0.class~sam2.class returns an int value
default public user(Main.class) sam0 using facade.class~sam2.Use class
  • User Includes the meaning that other developers use this pattern

facade.class


package sample;
public  class facade{
    int res;
    public facade(int condition){
        switch(condition){
          case  0 : res = new sam0().get();break; 
          case  1 : res = new sam1().get();break;
          default : res = new sam2().get();break;
        }
        this.res = res;
    }
    public int get(){return this.res;}
} 

sam01.class


package sample;
class sam0{ int get(){return 0;} }
class sam1{ int get(){return 1;} }
class sam2{ int get(){return 2;} }

user(Main.class)


import sample.facade;
class  Main {
  public static void main(String[] args){
    facade fd = new facade(8);
    System.out.println(fd.get());
  }
}

Recommended Posts

Facade Pattern
Facade pattern
Design pattern ~ Facade ~
Prototype pattern
Memento Pattern
Mediator pattern
Composite pattern
Observer Pattern
Builder Pattern
Strategy pattern
Iterator Pattern
Visitor pattern
Adapter Pattern
Proxy Pattern
Strategy Pattern
Composite Pattern
Singleton Pattern
Singleton pattern
Prototype Pattern
Decorator pattern
Flyweight Pattern
Decorator Pattern
Mediator Pattern
Visitor Pattern
Bridge pattern
What is the Facade pattern useful for?
abstract Factory Pattern
Design pattern ~ Builder ~
[Java] Strategy pattern
Design pattern ~ Visitor ~
Java design pattern
java callback pattern
Design pattern ~ Proxy ~
Design pattern ~ State ~
Factory Method Pattern
Design pattern ~ Strategy ~
Design pattern ~ Singleton ~
Design pattern (2): Builder
Design pattern (1): AbstractFactory
[Java] Singleton pattern
Design pattern ~ Command ~
Abstract Factory pattern
Design pattern ~ Iterator ~
What is Facade? ??
Design pattern ~ Bridge ~
Design pattern ~ Mediator ~
Template Method pattern
Design pattern ~ Decorator ~
Design pattern ~ Interpreter ~
Factory Method pattern
Design pattern ~ Observer ~
Design pattern ~ Prototype ~
[Java] Adapter pattern
Design pattern ~ Memento ~
Design pattern ~ Adapter ~
Design pattern ~ Flyweight ~
Java pattern memo