SlideShare a Scribd company logo
1 of 14
1
DESIGN PATTERNS :
Adapter Pattern
By
RAVI P. PATKI
(Associate Professor (IT)
Hope Foundation’s
International Institute of Information Technology
2
Agenda
 Introduction
 Problem in Software Design /code
 Definition of Adapter Pattern
 Solution to Problem in terms of
Adapter Pattern
 Implementation of adapter Pattern
Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
3
Introduction
This pattern is easy to understand as the real world is full
of adapters.
 For example consider a USB to Ethernet adapter. We
need this when we have an Ethernet interface on one end
and USB on the other.
Since they are incompatible with each other. we use an
adapter that converts one to other.
This example is pretty analogous to Object Oriented
Adapters.
In design, adapters are used when we have a class
(Client) expecting some type of object and we have an
object (Adaptee) offering the same features but exposing a
different interface.
Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
4
Introduction
Example
Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
5
Adapter pattern works as a bridge between two
incompatible interfaces.
This type of design pattern comes under structural
pattern as this pattern combines the capability of two
independent interfaces.
This pattern involves a single class which is
responsible to join functionalities of independent or
incompatible interfaces.
A real life example could be a case of card reader
which acts as an adapter between memory card and a
laptop.
You plug-in the memory card into card reader and card
reader into the laptop so that memory card can be read
via laptop.
Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Introduction
6
We are demonstrating use of Adapter pattern via
following example in which an audio player
device can play mp3 files only and wants to use
an advanced audio player capable of playing vlc
and mp4 files.
Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Implementation
7
Implementation
we have a MediaPlayer interface and a concrete class
AudioPlayer implementing the MediaPlayer interface.
AudioPlayer can play mp3 format audio files by default.
We are having another interface AdvancedMediaPlayer and
concrete classes implementing the AdvancedMediaPlayer
interface.
These classes can play vlc and mp4 format files.
We want to make AudioPlayer to play other formats as well.
 To attain this, we have created an adapter class MediaAdapter
which implements the MediaPlayer interface and uses
AdvancedMediaPlayer objects to play the required format.
AudioPlayer uses the adapter class MediaAdapter passing it the
desired audio type without knowing the actual class which can
play the desired format. AdapterPatternDemo, our demo class
will use AudioPlayer class to play various formats.
Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
8Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Implementation
9Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Implementation
10Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Implementation
11Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Implementation
12Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Implementation
13Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi
Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Implementation
14
THANK YOU
For further information please feel free to contact
Dr. Ravi Patki
ravip@isquareit.edu.in
Department of Information Technology,
Hope Foundation’s International Institute of Information Technology, I²IT
P-14, Rajiv Gandhi Infotech Park, Hinjawadi, MIDC Phase I
Pune – 411057
Tel +91 20 22933441
www.isquareit.edu.in; info@isquareit.edu.in

More Related Content

What's hot

What's hot (20)

Conformal Mapping - Introduction & Examples
Conformal Mapping - Introduction & ExamplesConformal Mapping - Introduction & Examples
Conformal Mapping - Introduction & Examples
 
Cloud Computing & Virtual Infrastructure
Cloud Computing & Virtual InfrastructureCloud Computing & Virtual Infrastructure
Cloud Computing & Virtual Infrastructure
 
What is DevOps?
What is DevOps?What is DevOps?
What is DevOps?
 
Artificial Intelligence - Introduction
Artificial Intelligence - IntroductionArtificial Intelligence - Introduction
Artificial Intelligence - Introduction
 
Introduction to TCP Protocol Suite
Introduction to TCP Protocol SuiteIntroduction to TCP Protocol Suite
Introduction to TCP Protocol Suite
 
State Pattern: Introduction & Implementation
State Pattern: Introduction  & Implementation State Pattern: Introduction  & Implementation
State Pattern: Introduction & Implementation
 
Human Computer Interaction - INPUT OUTPUT CHANNELS
Human Computer Interaction - INPUT OUTPUT CHANNELSHuman Computer Interaction - INPUT OUTPUT CHANNELS
Human Computer Interaction - INPUT OUTPUT CHANNELS
 
What Is Cascading Style Sheet?
What Is Cascading Style Sheet?What Is Cascading Style Sheet?
What Is Cascading Style Sheet?
 
Introduction To Assembly Language Programming
Introduction To Assembly Language ProgrammingIntroduction To Assembly Language Programming
Introduction To Assembly Language Programming
 
What Is LEX and YACC?
What Is LEX and YACC?What Is LEX and YACC?
What Is LEX and YACC?
 
Java as Object Oriented Programming Language
Java as Object Oriented Programming LanguageJava as Object Oriented Programming Language
Java as Object Oriented Programming Language
 
Superstructure and it's various components
Superstructure and it's various componentsSuperstructure and it's various components
Superstructure and it's various components
 
Types of Artificial Intelligence
Types of Artificial Intelligence Types of Artificial Intelligence
Types of Artificial Intelligence
 
Database Query Optimization
Database Query OptimizationDatabase Query Optimization
Database Query Optimization
 
Smart Closet Organizer
Smart Closet OrganizerSmart Closet Organizer
Smart Closet Organizer
 
Euler’s Theorem Homogeneous Function Of Two Variables
Euler’s Theorem Homogeneous Function Of  Two VariablesEuler’s Theorem Homogeneous Function Of  Two Variables
Euler’s Theorem Homogeneous Function Of Two Variables
 
Interrupt Handling with LPC2148
Interrupt Handling with LPC2148Interrupt Handling with LPC2148
Interrupt Handling with LPC2148
 
Differential Equation - Order Degree
Differential Equation - Order DegreeDifferential Equation - Order Degree
Differential Equation - Order Degree
 
Basics of Business Management
Basics of Business ManagementBasics of Business Management
Basics of Business Management
 
PIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC InterfacingPIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC Interfacing
 

Similar to Adapter Pattern: Introduction & Implementation (with examples)

IoT Based Smart Attendance System Using RFID and Google Sheet
IoT Based Smart Attendance System Using RFID and Google SheetIoT Based Smart Attendance System Using RFID and Google Sheet
IoT Based Smart Attendance System Using RFID and Google SheetIRJET Journal
 
IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”
IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”
IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”IRJET Journal
 
PI TOP: HARDWARE-ENABLED SUPERCOMPUTER
PI TOP: HARDWARE-ENABLED SUPERCOMPUTERPI TOP: HARDWARE-ENABLED SUPERCOMPUTER
PI TOP: HARDWARE-ENABLED SUPERCOMPUTERIRJET Journal
 
Mobile Application of Pet Adoption System
Mobile Application of Pet Adoption SystemMobile Application of Pet Adoption System
Mobile Application of Pet Adoption SystemIRJET Journal
 
Divyesh mehta resume
Divyesh mehta resumeDivyesh mehta resume
Divyesh mehta resumeDivyesh Mehta
 
SMART LEARNING ASSISTANT
SMART LEARNING ASSISTANTSMART LEARNING ASSISTANT
SMART LEARNING ASSISTANTIRJET Journal
 
Virtual Personal Assistant
Virtual Personal AssistantVirtual Personal Assistant
Virtual Personal AssistantIRJET Journal
 
IRJET- IoT based Smart Projector
IRJET-  	  IoT based Smart ProjectorIRJET-  	  IoT based Smart Projector
IRJET- IoT based Smart ProjectorIRJET Journal
 

Similar to Adapter Pattern: Introduction & Implementation (with examples) (20)

DAA Introduction to Algorithms & Application
DAA Introduction to Algorithms & ApplicationDAA Introduction to Algorithms & Application
DAA Introduction to Algorithms & Application
 
IoT Based Smart Attendance System Using RFID and Google Sheet
IoT Based Smart Attendance System Using RFID and Google SheetIoT Based Smart Attendance System Using RFID and Google Sheet
IoT Based Smart Attendance System Using RFID and Google Sheet
 
What Is High Performance-Computing?
What Is High Performance-Computing?What Is High Performance-Computing?
What Is High Performance-Computing?
 
DESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy PatternsDESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy Patterns
 
Introduction To Design Pattern
Introduction To Design PatternIntroduction To Design Pattern
Introduction To Design Pattern
 
Basics of Computer Graphics
Basics of Computer GraphicsBasics of Computer Graphics
Basics of Computer Graphics
 
IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”
IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”
IRJET- Student Teacher Integrated Network Ground – “S.T.I.N.G”
 
Supervised Learning in Cybersecurity
Supervised Learning in CybersecuritySupervised Learning in Cybersecurity
Supervised Learning in Cybersecurity
 
PI TOP: HARDWARE-ENABLED SUPERCOMPUTER
PI TOP: HARDWARE-ENABLED SUPERCOMPUTERPI TOP: HARDWARE-ENABLED SUPERCOMPUTER
PI TOP: HARDWARE-ENABLED SUPERCOMPUTER
 
Mobile Application of Pet Adoption System
Mobile Application of Pet Adoption SystemMobile Application of Pet Adoption System
Mobile Application of Pet Adoption System
 
Importance of Theory of Computations
Importance of Theory of ComputationsImportance of Theory of Computations
Importance of Theory of Computations
 
Divyesh mehta resume
Divyesh mehta resumeDivyesh mehta resume
Divyesh mehta resume
 
SMART LEARNING ASSISTANT
SMART LEARNING ASSISTANTSMART LEARNING ASSISTANT
SMART LEARNING ASSISTANT
 
Red Black Tree (and Examples)
Red Black Tree (and Examples)Red Black Tree (and Examples)
Red Black Tree (and Examples)
 
dinesh_5
dinesh_5dinesh_5
dinesh_5
 
Virtual Personal Assistant
Virtual Personal AssistantVirtual Personal Assistant
Virtual Personal Assistant
 
What Is Smart Computing?
What Is Smart Computing?What Is Smart Computing?
What Is Smart Computing?
 
IRJET- IoT based Smart Projector
IRJET-  	  IoT based Smart ProjectorIRJET-  	  IoT based Smart Projector
IRJET- IoT based Smart Projector
 
Industrial Internet of Things (IIoT)
Industrial Internet of Things (IIoT)Industrial Internet of Things (IIoT)
Industrial Internet of Things (IIoT)
 
NP-Complete Problem
NP-Complete Problem NP-Complete Problem
NP-Complete Problem
 

More from International Institute of Information Technology (I²IT)

More from International Institute of Information Technology (I²IT) (20)

Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
Understanding Natural Language Processing
Understanding Natural Language ProcessingUnderstanding Natural Language Processing
Understanding Natural Language Processing
 
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
Professional Ethics & Etiquette: What Are They & How Do I Get Them?Professional Ethics & Etiquette: What Are They & How Do I Get Them?
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
 
Writing Skills: Importance of Writing Skills
Writing Skills: Importance of Writing SkillsWriting Skills: Importance of Writing Skills
Writing Skills: Importance of Writing Skills
 
Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself
 
Servlet: A Server-side Technology
Servlet: A Server-side TechnologyServlet: A Server-side Technology
Servlet: A Server-side Technology
 
What Is Jenkins? Features and How It Works
What Is Jenkins? Features and How It WorksWhat Is Jenkins? Features and How It Works
What Is Jenkins? Features and How It Works
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Hypothesis-Testing
Hypothesis-TestingHypothesis-Testing
Hypothesis-Testing
 
Data Science, Big Data, Data Analytics
Data Science, Big Data, Data AnalyticsData Science, Big Data, Data Analytics
Data Science, Big Data, Data Analytics
 
Sentiment Analysis in Machine Learning
Sentiment Analysis in  Machine LearningSentiment Analysis in  Machine Learning
Sentiment Analysis in Machine Learning
 
Data Visualization - How to connect Microsoft Forms to Power BI
Data Visualization - How to connect Microsoft Forms to Power BIData Visualization - How to connect Microsoft Forms to Power BI
Data Visualization - How to connect Microsoft Forms to Power BI
 
AVL Tree Explained
AVL Tree ExplainedAVL Tree Explained
AVL Tree Explained
 
Yoga To Fight & Win Against COVID-19
Yoga To Fight & Win Against COVID-19Yoga To Fight & Win Against COVID-19
Yoga To Fight & Win Against COVID-19
 
LR(0) PARSER
LR(0) PARSERLR(0) PARSER
LR(0) PARSER
 
Programming with LEX & YACC
Programming with LEX & YACCProgramming with LEX & YACC
Programming with LEX & YACC
 
Land Pollution - Causes, Effects & Solution
Land Pollution - Causes, Effects & SolutionLand Pollution - Causes, Effects & Solution
Land Pollution - Causes, Effects & Solution
 
Sampling Theorem and Band Limited Signals
Sampling Theorem and Band Limited SignalsSampling Theorem and Band Limited Signals
Sampling Theorem and Band Limited Signals
 
Types of Sampling in Analog Communication
Types of Sampling in Analog CommunicationTypes of Sampling in Analog Communication
Types of Sampling in Analog Communication
 
Pulse Modulation - Classification & Case Study
Pulse Modulation - Classification & Case StudyPulse Modulation - Classification & Case Study
Pulse Modulation - Classification & Case Study
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Adapter Pattern: Introduction & Implementation (with examples)

  • 1. 1 DESIGN PATTERNS : Adapter Pattern By RAVI P. PATKI (Associate Professor (IT) Hope Foundation’s International Institute of Information Technology
  • 2. 2 Agenda  Introduction  Problem in Software Design /code  Definition of Adapter Pattern  Solution to Problem in terms of Adapter Pattern  Implementation of adapter Pattern Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
  • 3. 3 Introduction This pattern is easy to understand as the real world is full of adapters.  For example consider a USB to Ethernet adapter. We need this when we have an Ethernet interface on one end and USB on the other. Since they are incompatible with each other. we use an adapter that converts one to other. This example is pretty analogous to Object Oriented Adapters. In design, adapters are used when we have a class (Client) expecting some type of object and we have an object (Adaptee) offering the same features but exposing a different interface. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
  • 4. 4 Introduction Example Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
  • 5. 5 Adapter pattern works as a bridge between two incompatible interfaces. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plug-in the memory card into card reader and card reader into the laptop so that memory card can be read via laptop. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Introduction
  • 6. 6 We are demonstrating use of Adapter pattern via following example in which an audio player device can play mp3 files only and wants to use an advanced audio player capable of playing vlc and mp4 files. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Implementation
  • 7. 7 Implementation we have a MediaPlayer interface and a concrete class AudioPlayer implementing the MediaPlayer interface. AudioPlayer can play mp3 format audio files by default. We are having another interface AdvancedMediaPlayer and concrete classes implementing the AdvancedMediaPlayer interface. These classes can play vlc and mp4 format files. We want to make AudioPlayer to play other formats as well.  To attain this, we have created an adapter class MediaAdapter which implements the MediaPlayer interface and uses AdvancedMediaPlayer objects to play the required format. AudioPlayer uses the adapter class MediaAdapter passing it the desired audio type without knowing the actual class which can play the desired format. AdapterPatternDemo, our demo class will use AudioPlayer class to play various formats. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
  • 8. 8Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Implementation
  • 9. 9Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Implementation
  • 10. 10Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Implementation
  • 11. 11Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Implementation
  • 12. 12Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Implementation
  • 13. 13Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in Implementation
  • 14. 14 THANK YOU For further information please feel free to contact Dr. Ravi Patki ravip@isquareit.edu.in Department of Information Technology, Hope Foundation’s International Institute of Information Technology, I²IT P-14, Rajiv Gandhi Infotech Park, Hinjawadi, MIDC Phase I Pune – 411057 Tel +91 20 22933441 www.isquareit.edu.in; info@isquareit.edu.in