0% found this document useful (0 votes)
72 views3 pages

Understanding the Adapter Pattern

Uploaded by

ionutio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views3 pages

Understanding the Adapter Pattern

Uploaded by

ionutio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd

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)

You might also like