SlideShare a Scribd company logo
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

Conformal Mapping - Introduction & Examples
Conformal Mapping - Introduction & ExamplesConformal Mapping - Introduction & Examples
Conformal Mapping - Introduction & Examples
International Institute of Information Technology (I²IT)
 
Cloud Computing & Virtual Infrastructure
Cloud Computing & Virtual InfrastructureCloud Computing & Virtual Infrastructure
Cloud Computing & Virtual Infrastructure
International Institute of Information Technology (I²IT)
 
What is DevOps?
What is DevOps?What is DevOps?
Artificial Intelligence - Introduction
Artificial Intelligence - IntroductionArtificial Intelligence - Introduction
Artificial Intelligence - Introduction
International Institute of Information Technology (I²IT)
 
Introduction to TCP Protocol Suite
Introduction to TCP Protocol SuiteIntroduction to TCP Protocol Suite
State Pattern: Introduction & Implementation
State Pattern: Introduction  & Implementation State Pattern: Introduction  & Implementation
State Pattern: Introduction & Implementation
International Institute of Information Technology (I²IT)
 
Human Computer Interaction - INPUT OUTPUT CHANNELS
Human Computer Interaction - INPUT OUTPUT CHANNELSHuman Computer Interaction - INPUT OUTPUT CHANNELS
Human Computer Interaction - INPUT OUTPUT CHANNELS
International Institute of Information Technology (I²IT)
 
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
International Institute of Information Technology (I²IT)
 
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
International Institute of Information Technology (I²IT)
 
Superstructure and it's various components
Superstructure and it's various componentsSuperstructure and it's various components
Superstructure and it's various components
International Institute of Information Technology (I²IT)
 
Types of Artificial Intelligence
Types of Artificial Intelligence Types of Artificial Intelligence
Database Query Optimization
Database Query OptimizationDatabase Query Optimization
Smart Closet Organizer
Smart Closet OrganizerSmart 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
International Institute of Information Technology (I²IT)
 
Interrupt Handling with LPC2148
Interrupt Handling with LPC2148Interrupt Handling with LPC2148
Differential Equation - Order Degree
Differential Equation - Order DegreeDifferential Equation - Order Degree
Differential Equation - Order Degree
International Institute of Information Technology (I²IT)
 
Basics of Business Management
Basics of Business ManagementBasics of Business Management
PIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC InterfacingPIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC Interfacing
International Institute of Information Technology (I²IT)
 

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)

DAA Introduction to Algorithms & Application
DAA Introduction to Algorithms & ApplicationDAA Introduction to Algorithms & Application
DAA Introduction to Algorithms & Application
International Institute of Information Technology (I²IT)
 
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
IRJET Journal
 
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
Introduction To Design Pattern
Introduction To Design PatternIntroduction To Design Pattern
Basics of Computer Graphics
Basics of Computer GraphicsBasics 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”
IRJET Journal
 
Supervised Learning in Cybersecurity
Supervised Learning in CybersecuritySupervised Learning in Cybersecurity
Supervised Learning in Cybersecurity
International Institute of Information Technology (I²IT)
 
PI TOP: HARDWARE-ENABLED SUPERCOMPUTER
PI TOP: HARDWARE-ENABLED SUPERCOMPUTERPI TOP: HARDWARE-ENABLED SUPERCOMPUTER
PI TOP: HARDWARE-ENABLED SUPERCOMPUTER
IRJET Journal
 
Mobile Application of Pet Adoption System
Mobile Application of Pet Adoption SystemMobile Application of Pet Adoption System
Mobile Application of Pet Adoption System
IRJET Journal
 
Importance of Theory of Computations
Importance of Theory of ComputationsImportance of Theory of Computations
Importance of Theory of Computations
International Institute of Information Technology (I²IT)
 
Divyesh mehta resume
Divyesh mehta resumeDivyesh mehta resume
Divyesh mehta resume
Divyesh Mehta
 
SMART LEARNING ASSISTANT
SMART LEARNING ASSISTANTSMART LEARNING ASSISTANT
SMART LEARNING ASSISTANT
IRJET Journal
 
Red Black Tree (and Examples)
Red Black Tree (and Examples)Red Black Tree (and Examples)
Virtual Personal Assistant
Virtual Personal AssistantVirtual Personal Assistant
Virtual Personal Assistant
IRJET Journal
 
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
IRJET Journal
 
Industrial Internet of Things (IIoT)
Industrial Internet of Things (IIoT)Industrial Internet of Things (IIoT)
Industrial Internet of Things (IIoT)
International Institute of Information Technology (I²IT)
 
NP-Complete Problem
NP-Complete Problem NP-Complete Problem

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)

Minimization of DFA
Minimization of DFAMinimization of DFA
Understanding Natural Language Processing
Understanding Natural Language ProcessingUnderstanding Natural Language Processing
Understanding Natural Language Processing
International Institute of Information Technology (I²IT)
 
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?
International Institute of Information Technology (I²IT)
 
Writing Skills: Importance of Writing Skills
Writing Skills: Importance of Writing SkillsWriting Skills: Importance of Writing Skills
Writing Skills: Importance of Writing Skills
International Institute of Information Technology (I²IT)
 
Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself
International Institute of Information Technology (I²IT)
 
Servlet: A Server-side Technology
Servlet: A Server-side TechnologyServlet: 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
International Institute of Information Technology (I²IT)
 
Cloud Computing
Cloud ComputingCloud Computing
Hypothesis-Testing
Hypothesis-TestingHypothesis-Testing
Data Science, Big Data, Data Analytics
Data Science, Big Data, Data AnalyticsData Science, Big Data, Data Analytics
Data Science, Big Data, Data Analytics
International Institute of Information Technology (I²IT)
 
Sentiment Analysis in Machine Learning
Sentiment Analysis in  Machine LearningSentiment Analysis in  Machine Learning
Sentiment Analysis in Machine Learning
International Institute of Information Technology (I²IT)
 
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
International Institute of Information Technology (I²IT)
 
AVL Tree Explained
AVL Tree ExplainedAVL 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
International Institute of Information Technology (I²IT)
 
LR(0) PARSER
LR(0) PARSERLR(0) PARSER
Programming with LEX & YACC
Programming with LEX & YACCProgramming with LEX & YACC
Land Pollution - Causes, Effects & Solution
Land Pollution - Causes, Effects & SolutionLand Pollution - Causes, Effects & Solution
Land Pollution - Causes, Effects & Solution
International Institute of Information Technology (I²IT)
 
Sampling Theorem and Band Limited Signals
Sampling Theorem and Band Limited SignalsSampling Theorem and Band Limited Signals
Sampling Theorem and Band Limited Signals
International Institute of Information Technology (I²IT)
 
Types of Sampling in Analog Communication
Types of Sampling in Analog CommunicationTypes of Sampling in Analog Communication
Types of Sampling in Analog Communication
International Institute of Information Technology (I²IT)
 
Pulse Modulation - Classification & Case Study
Pulse Modulation - Classification & Case StudyPulse Modulation - Classification & Case Study
Pulse Modulation - Classification & Case Study
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

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 

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