Link: Turkey and Duck
The Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets clases work together that couldn't otherwise because of incompatible interfaces.
- Object Adapters: The Adapter class is composed with the object of Adaptee
- Class Adapters: The Adapter class subclasses both the Target and Adaptee interfaces
classDiagram
class Target {
void request()
}
class Adaptee {
void specificRequest()
}
class ClientGame {
// main.cpp
}
class Adapter {
Adaptee adaptee
void request()
}
ClientGame "interacts with" --> Target
Adapter "implements" ..> Target
Adapter "composition" --> Adaptee