The Class Adapter Pattern


Adapter Pattern 

The Adapter pattern allows you to provide an object instance to a client that has a dependency on an interface that your instance does not implement.

The implementation of adapter pattern called Class Adapter 

Exist two ways of the implements the adapter pattern, bellow you can see the class adapter pattern.

Now think that we already have a great implementation of code that do anything.

But the client can't be altered to fit the desired interface because 



Then an Adapter class is created that fulfills the desired interface of the client and basically will implements the method of the interface that calls the method of the our great implementation.

And finally, below the client using the adapter.

This was a simple implementation of class adapter only to learn the principle of the pattern. In real world the implementations will be more hard but the principle will remain being simple.

Main photo by Steve Johnson at Unsplash.

Thank you for reading and if you have a question use the comments!

Best regards,
Daniel Maurer