Adapter Pattern
Last updated
Last updated
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
Wrapper
If we want to use an existing library that has an interface different than our code requires.
If we want to easily change the existing libraries or have more than one used in the code, so we can define one Adapter interface, and adapt any number of different libraries in the different Adapter classes (Open / Closed Principle).
Target: defines the interface our code needs.
Adaptee: the existing library that needs to be adapted.
Adapter: adapts the adaptee to the required target interface.
Source Code
UML
// TODO
// TODO
You can find the tests here.