Adapter pattern

[1] It is often used to make existing classes work with others without modifying their source code.

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

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