Bridge Pattern

Separate the side that implements the method and the side that uses the method, and associate both with an instance of the implementation class
-The implementation side defines and embodies the method
- The user owns the implementation side instance in the field and uses the implementation side method via the instance </ font>

Design Pattarm MENU

Check with the following class structure

class Explanation
Mounting side abstract
class superSam
Define method
Mounting side sam.class Implemented superSam
User side useSam.class Use the method on the implementation side
  • User Includes the meaning that other developers use this pattern

Create a class below

superSam.class


abstract class superSam{
  String str;
  superSam(String str){this.str=str;}
  abstract void todo();
}

sam.class


class sam extends superSam{
  sam(String str){super(str);}
  void todo(){System.out.println(super.str);}
}

useSam.class


class useSam{
  sam sam;
  useSam(sam sam){this.sam=sam;}
  void exec(){sam.todo();}
}

user(Main.class)


public static void main(String[] args){
  useSam use1 = new useSam (new sam("Hello java"));
    use1.exec();
}}

Recommended Posts

Bridge Pattern
Bridge pattern
Design pattern ~ Bridge ~
Prototype pattern
Memento Pattern
Mediator pattern
Composite pattern
Observer Pattern
Command Pattern
Builder Pattern
Strategy pattern
Iterator Pattern
Visitor pattern
Adapter Pattern
Proxy Pattern
Strategy Pattern
Composite Pattern
Singleton Pattern
Singleton pattern
Prototype Pattern
Facade Pattern
Decorator pattern
Flyweight Pattern
Decorator Pattern
Mediator Pattern
Facade pattern
Visitor Pattern
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 ~ Composite ~
Design pattern (2): Builder
Design pattern (1): AbstractFactory
[Java] Singleton pattern
Design pattern ~ Command ~
Abstract Factory pattern
Design pattern ~ Iterator ~
Design pattern ~ Facade ~
Design pattern ~ Mediator ~
Template Method pattern
Design pattern ~ Decorator ~
Template Method Pattern
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