Adapter Design Pattern
Learn about the adapter design pattern.
We'll cover the following...
Overview
We often use adapters in real life. Suppose we traveled from the US to the UK with a laptop. Our charger won’t plug directly into the power outlet in the UK because they’re incompatible. We can solve this problem by placing an adapter between the plug and the power socket.
In programming, the concept is the same. Suppose that we have code that interacts with the interface of the class. But we find out that the code we’ve written isn’t compatible with the new interface of the class. And let’s assume that we don’t want to change the code (remember the laptop charger example, as we may not want to change our charger to make it compatible with the UK outlet). Just like our real-world ...