• Albert Bennett

Design Patterns : Adapter

Updated: Jul 12, 2021

As always here is the link to the GitHub repo :)

If this post has helped you feel free to like, comment and share.

This post is all about the adapter pattern. What is it, when is it used, etc.

The adaptive pattern is all about converting one interface/ object to another. Simple as...

Here is a diagram of how it all works together.

Target (ITarget): This defines the object that the client is expecting to get.

Adaptee: This is the object that needs to be adapted.

Adapter: This object holds a reference to the adaptee. It is responsible for converting the adaptee methods into ones that the client expects to see.

Here is an example of how this pattern can be implemented. As you can see our client class is only compatible with the ITarget interface and not the Adaptee.

I hope that this helps you to understand the adapter pattern.

<< More Design Patterns

3 views0 comments

Recent Posts

See All