Adapter Design Pattern
The adapter pattern helps us to connect or communicate with two or more than two interfaces that are not compatible with each other. In a simple word if we have to consume data from a source which our current implementation doesn't support then we can use this pattern to communicate with incompatible sources.
When to use
- Accessing data from incompatible sources or interfaces.
- Don't want to modify legacy code because of its dependency but need to use it anyhow.
- Scenario where you have to follow open/closed principle
- You could extend each subclass and put the missing function- ality into new child classes. However, you’ll need to duplicate the code across all of these new classes, which smells bad.