Presentation on
Adapter Design Pattern
Presented by
Md. Zabirul Islam (1507110)
Tanim Ahmed (1507113)
Md. Motaleb Hossen Manik (1507114)
1
DoYou KnowWhat It Is Adapter?
▪ The adapter pattern convert the interface of a class into another interface that
clients expect. Adapter lets classes work together that couldn’t otherwise because
of incompatible interfaces.
▪ Wikipedia says…
▪ In software engineering, the adapter pattern is a software design pattern that
allows the interface of an existing class to be used as another interface. It is often
used to make existing classes work with others without modifying their source
code.
2
Real world example
Consider that you have some pictures in your memory card and you need to transfer them to your
computer.
In order to transfer them you need some kind of adapter that is compatible with your computer ports
so that you can attach memory card to your computer.
In this case card reader is an adapter. Another example would be the famous power adapter;
a three legged plug can't be connected to a two pronged outlet,
it needs to use a power adapter that makes it compatible with the two pronged outlet.
Yet another example would be a translator translating words spoken by one person to another
3
Adapter…
4
Another Example

suppose I am a ProgrammingTeacher, and I have two types of
students in my class, the American students and the Bangladeshi
students, since my American students don’t understand Bangla, I
have to have a translator that will translate my lectures to my
American students.
In this example, a Student class will be theTarget, the translator will
be the Adapter, and the American students will be the Adaptee, like
the class diagram below:
5
Class Diagram Of Adapter Pattern
6
student
translator American student
Context
▪ You are building an inheritance hierarchy and want to
incorporate into it an existing class.
▪ The reused class is also often already part of its own
inheritance hierarchy.
7
Problem
▪ Some problems are faced during designing Adapter design pattern
▪ When there is polymorphism
▪ There may have function with same name but with different
signature
▪ User may have written a separate class for a specific task. But as the
user should go through Polymorphism, this separate class is unused.
8
Adapter Pattern
Problem Continued…
9
Here is already written class called xyzcircle that deals with
circles already. But we can’t use directly because we want to
preserve polymorphic behavior with Shape
Adapter Pattern
Forces
▪ Some languages may not support multiple inheritances (e.g. Java)
▪ More forwarding requests
▪ Increase in the overhead
▪ Adapter chaining in created to reach to specific type
▪ Complex adaptation
10
11
Adapter Pattern Design example
Conclusion
▪ In Adapter Design Pattern…..
▪ Provide the adapter between two different classes or
interfaces
▪ Useful pattern which promotes reuse of software
components.
12
References
▪ 1. https://www.slideshare.net/adeelr456/adapter-design-pattern-
45257387
▪ 2.https://www.slideshare.net/adeelr/qid=4ce8b50c-e14a-4cbb-8b62-
82ba26259f22&v=&b=&from_search=2
13
ThankYou
14

Adapter design pattern

  • 1.
    Presentation on Adapter DesignPattern Presented by Md. Zabirul Islam (1507110) Tanim Ahmed (1507113) Md. Motaleb Hossen Manik (1507114) 1
  • 2.
    DoYou KnowWhat ItIs Adapter? ▪ The adapter pattern convert the interface of a class into another interface that clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. ▪ Wikipedia says… ▪ In software engineering, the adapter pattern is a software design pattern that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code. 2
  • 3.
    Real world example Considerthat you have some pictures in your memory card and you need to transfer them to your computer. In order to transfer them you need some kind of adapter that is compatible with your computer ports so that you can attach memory card to your computer. In this case card reader is an adapter. Another example would be the famous power adapter; a three legged plug can't be connected to a two pronged outlet, it needs to use a power adapter that makes it compatible with the two pronged outlet. Yet another example would be a translator translating words spoken by one person to another 3
  • 4.
  • 5.
    Another Example  suppose Iam a ProgrammingTeacher, and I have two types of students in my class, the American students and the Bangladeshi students, since my American students don’t understand Bangla, I have to have a translator that will translate my lectures to my American students. In this example, a Student class will be theTarget, the translator will be the Adapter, and the American students will be the Adaptee, like the class diagram below: 5
  • 6.
    Class Diagram OfAdapter Pattern 6 student translator American student
  • 7.
    Context ▪ You arebuilding an inheritance hierarchy and want to incorporate into it an existing class. ▪ The reused class is also often already part of its own inheritance hierarchy. 7
  • 8.
    Problem ▪ Some problemsare faced during designing Adapter design pattern ▪ When there is polymorphism ▪ There may have function with same name but with different signature ▪ User may have written a separate class for a specific task. But as the user should go through Polymorphism, this separate class is unused. 8
  • 9.
    Adapter Pattern Problem Continued… 9 Hereis already written class called xyzcircle that deals with circles already. But we can’t use directly because we want to preserve polymorphic behavior with Shape
  • 10.
    Adapter Pattern Forces ▪ Somelanguages may not support multiple inheritances (e.g. Java) ▪ More forwarding requests ▪ Increase in the overhead ▪ Adapter chaining in created to reach to specific type ▪ Complex adaptation 10
  • 11.
  • 12.
    Conclusion ▪ In AdapterDesign Pattern….. ▪ Provide the adapter between two different classes or interfaces ▪ Useful pattern which promotes reuse of software components. 12
  • 13.
    References ▪ 1. https://www.slideshare.net/adeelr456/adapter-design-pattern- 45257387 ▪2.https://www.slideshare.net/adeelr/qid=4ce8b50c-e14a-4cbb-8b62- 82ba26259f22&v=&b=&from_search=2 13
  • 14.