Adaptor Pattern

Purpose

The term adaptor comes from the general lexicon.

An adapter (also known as a wrapper) translates one interface for a class into a compatible interface. An adapter allows classes to work together that normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface. The adapter translates calls to its interface into calls to the original interface. The adapter is also used to transform data into appropriate forms. For instance, if multiple boolean values are stored as a single integer but your consumer requires a 'true'/'false', the adapter would be responsible for extracting the appropriate values from the integer value.

Structure

See Wikipedia entry.

Related Patterns


 cappello@cs.ucsb.edu © Copyright 2010 Peter Cappello                                           2010.04.29