Adaptor Pattern

(from Design Patterns)

Synopsis

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

Context

You want to use an existing class whose interface does not match the one you need.

Forces

Solution

Compose the existing object (the subject) within an Adaptor object that implements the desired interface. The Adaptor forwards to the subject while possibly performing additional actions.

Consequences

Implementation

See Design Patterns for sample code.

Known Uses


Thomas Minka
Last modified: Fri Jan 17 18:37:18 EST 1997