Html/Javascript widget

Monday 29 August 2022

Adapter

The adapter pattern is a structural pattern Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy (also known as wrapper, an alternative naming shared with the decorator pattern) that allows the interface of an existing class to be used as another interface.
    The adapter design pattern solves problems like:
  • How can a class be reused that does not have an interface that a client requires?
  • How can classes that have incompatible interfaces work together?
  • How can an alternative interface be provided for a class?
    The adapter design pattern describes how to solve such problems:
  1. Define a separate adapter class that converts the (incompatible) interface of a class (adaptee) into another interface (target) clients require.
  2. Work through an adapter to work with (reuse) classes that do not have the required interface.

The key idea in this pattern is to work through a separate adapter that adapts the interface of an (already existing) class without changing it.

No comments:

Post a Comment