Adapter: Adapter. A Socket Attaches To A Ratchet, Provided That The Size of The
Adapter: Adapter. A Socket Attaches To A Ratchet, Provided That The Size of The
Adapter: Adapter. A Socket Attaches To A Ratchet, Provided That The Size of The
Adapter
Object Diagram
for Adapter using
Socket Adapter
Example
Problem
• An "off the shelf" component offers compelling
functionality that you would like reuse, but its "view of the
world" is not compatible with the philosophy and
architecture of the system currently being developed
Structural Adapter
Illustration: Problem
The classes in the tool kit (Text View in figure ) may not be
exactly what the client needs, so it becomes difficult for the
client to reuse such a class directly.
Due to this difficulty one may be tempted to duplicate the code
which will cause redundancy.
Structural Adapter
Solution:
One way to solve this problem is to make the client class
(TextShape) to adapt the Tool Kit Class (TextView) and
modify the interface to suit there application. This can be
done in two ways
1> By additionally inheriting the TextView Class or
2> Keeping a reference of the tool kit class inside the Test
Shape Class.
1
Structural Adapter
Model: Adapter object Pattern