Adapter

Adapters allow classes that normally have incompatible interfaces to work with each other. Often they are a pass through mechanism (ie client calls adapter, adapter calls other object) although sometimes they do a bit more logic.

Think of the adapters you have as computers change their hardware interface. mini-display port to vga for example. A lot of monitors do not support mini-display port natively (interface on the mac lap tops). To make it work, you need an adapter so that on one end, you can plug in a vga or hdmi cable and on the other end, the adapter has a mini display port plug that fits into the laptop.

Quick Reference

Pattern Name Adapter
Other Names Wrapper
Classification Class and Object Structural
Intent Converts the interface of one class into the interface a client expects. Allows classes which normally have incompatible interfaces to work with each other

General Structure

An adapter can be designed in two different ways and depending on how the objects are structured, their pattern classification is different.

Class Structural

The adapter is derived from two parents.

Object Structural

Object Composition Method

Example

results matching ""

    No results matching ""