skip to Main Content

Welcome

Say hello to the toggle bar. This is an optional section you can use to display any content you'd like. Simply select a page from the theme panel and the content of the page will display here. You can even use the drag and drop builder to create this! This is a perfect place for your company mission statement, alerts, notices or anything else.

Get In Touch

Email: support@total.com
Phone: 1-800-Total-Theme
Address: Las Vegas, Nevada

Our Location

togglebar-map

Adapter Pattern

Post Series: Structual Design Pattern

Adapter pattern acts as a bridge between two incompatible interfaces. This pattern involves a single class called adapter which is responsible for communication between two independent or incompatible interfaces.

 

ITarget: This is an interface which is used by the client to achieve its functionality/request.
Adapter: This is a class which implements the ITarget interface and inherits the Adaptee class. It is responsible for communication between Client and Adaptee.
Adaptee: This is a class which have the functionality, required by the client. However, its interface is not compatible with the client.
Client: This is a class which interact with a type that implements the ITarget interface. However, the communication class called adaptee, is not compatible with the client

Implement

Usage

  1. Allow a system to use classes of another system that is incompatible with it.
  2. Allow communication between new and already existing system which are independent to each other
  3. Ado.Net SqlAdapter, OracleAdapter, MySqlAdapter are best example of Adapter Pattern.

Note

  1. Internally, Adapter use Factory design pattern for creating objects. But it can also use Builder design pattern and prototype design pattern for creating product. It completely depends upon your implementation for creating products.
  2. Adapter can be used as an alternative to Facade to hide platform-specific classes.
  3. When Adapter, Builder, and Prototype define a factory for creating the products, we should consider the following points :
    1. Adapter use the factory for creating objects of several classes.
    2. Builder use the factory for creating a complex product by using simple objects and a step by step approach.
    3. Prototype use the factory for building a product by copying an existing product.

Resource

http://www.dotnettricks.com/learn/designpatterns/adapter-design-pattern-dotnet

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top