Adapter Design Pattern

Sometimes we could encountered a situation when we have a completely developed class and we are not allowed to modify it but we have to communicate with it. In that case we have to create and adapter to enable the class to communicate with us.

For example, let’s suppose that we developed a Log Engine as a library and that we shared this library with  all developers in the company. In this Log Engine we are logging all events to Windows Events. If a developer wants to use our library to log all events to the database, we should create an Adapter class to wrap our Log Engine and start logging to the database.

The Adapter Pattern could help us to wrap up an noncommunicable class to become suitable with what it’s requested from the consumer class.

Adapter Design is very useful for the system integration when some other components have to be adapted by the existing system.

Adapter Design Pattern Structure

Class Diagram

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s