Adapter pattern

An adapter can be used when the wrapper must respect a particular interface and must support polymorphic behavior.

In this situation, the adapter makes calls to the instance of the wrapped object.

A compile time solution is: However, suppose that the format of the string data must be varied.

A compile time solution is to use inheritance: and perhaps create the correctly "formatting" object at runtime by means of the factory pattern.

This parameter will be passed to an instance member of [ClassName]To[Interface]Adapter.

A sample UML class diagram for the adapter design pattern. [ 5 ]
The object adapter pattern expressed in UML
The object adapter pattern expressed in LePUS3
The class adapter pattern expressed in UML .
The class adapter pattern expressed in LePUS3