Intent
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
Motivation
Sometimes a toolkit or class library can not be used because its interface is incompatible with the interface required by an application
We can not change the library interface, since we may not have its source code
Even if we did have the source code, we probably should not change the library for each domain-specific application
Solution:
When to use:
You want to use an existing class, and its interface does not match the one you need
You want to create a reusable class that cooperates with unrelated classes with incompatible interfaces



0 comments:
Post a Comment