Adapter pattern
Problem:
We have two incompatible interfaces;
<<interface>>
<<interface>>
run() walk()
We don’t want to change our code;
We don’t have access to the other interface code;
Solution:
>> We create an adapter that will make those interfaces compatibile <<
Adapter
Client <<interface>>
walk()
Adaptor Adaptee
walk() run()
Consequences:
Advantages:
Adapter works with Adaptee and any subclass of it.
Adapter can add functionality to Adaptee and its subclasses.
Disadvantages:
Cannot override methods in Adaptee.
Cannot reuse Adapter with subclasses of Target.
Adapter and Adaptee are different objects.
(Need to maintain relation between Adaptee and his Adapter)