CSC/ECE 517 Fall 2012/ch2a 2w16 dp
Adapter Design Pattern
In computer programming, the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface.
Introduction
An adapter allows classes to work together that normally could not because of incompatible interfaces.It “wraps” its own interface around the interface of a pre-existing class. It may also translate data formats from the caller to a form needed by the callee.
Adapter pattern is also used to translate calls made by a user to any wrapped interface. e.g. for efficiency, a data structure may be used to store multiple values in it. but it becomes difficult for the user to understand them and edit them, so the adapter class may simplify the call to the wrapped class, and provide users with only the variables/methods that he might be interested in. Another scenario where adapter patterns may be used is that in a system, different users may be given different access level depending of their classification, so instead of changing the whole design, a number of adapter classes will do the work, instead of modifying the whole design.