Adapter Design Pattern04:33

  • 0
Published on January 4, 2018

In this session we will discuss
1. What is Adapter Design Pattern
2. Implementation Guidelines of Adapter design pattern
3. And will take a look at an example to implement Adapter design pattern

Please refer to the previous parts of the tutorial before proceeding.

Adapter Design Pattern : The Adapter design pattern is one of the twenty-three well-known GoF design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse.

As per the GOF definition Adapter “Match interfaces of different classes”, this Means, an adapter allows two incompatible interfaces to work together
1. In software engineering, the adapter pattern is a software design pattern that allows the interface of an existing class to be used from another interface. It is often used to make existing classes work with others without modifying their source code.
2. Leveraging on Adapter pattern Improves reusability of older functionality

Implementation Guidelines : We need to Choose Adapter Design Pattern when
1. A class need to be reused that does not have an interface that a client requires?
2. We need to work through a separate Adapter that adapts the interface of an existing class without changing it
3. Clients don’t know whether they work with a Target class directly or through an Adapter with a class that does not have the Target interface

Example :
1. The best example for the adapter pattern is based around AC power adapter
2. The AC adapter knows how to deal with both sides, acting as a middleman – this behavior of Ac Power Adapter is the perfect example of adapter pattern

Client class is used to communicate with the Adapter class that implements the ITarget interface. In other words, this is the class used for creating the instance of Adapter class.

ITarget here represents an interface created to make client achieve its purpose.

The Adapter class implements the ITarget interface and inherits the Adaptee class as well.

Adaptee class contains the main functionality that client is expecting.

For the code used in the demo, please refer to our blog using the link below.

Text version of the video

Slides

Design Patterns Tutorial playlist

Design Patterns Text articles and slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

https://cafeadobro.ro/

https://www.stagebox.uk/wp-includes/depo10-bonus10/

https://iavec.com.br/

Enjoyed this video?
"No Thanks. Please Close This Box!"