What is the Adapter Pattern
The Adapter Pattern is a structural design pattern that allows incompatible interfaces to work together. It acts as a bridge between the client and a class with a different interface by converting the interface of one class into an interface expected by the client.
This pattern is useful when integrating existing classes that do not match the interface required by the system.
Pattern Structure
The Adapter Pattern typically involves:
- Client – the code that expects to use a specific target interface.
- Target – the interface expected by the client.
- Adaptee – an existing class with an incompatible interface.
- Adapter – implements the target interface and translates the client requests to the adaptee.