SlideShare a Scribd company logo
1 of 18
Adapter & Proxy Pattern
Philip zhong Feb, 2014
Agenda
•
•

•
•
•
•
•
•
•
•

Pattern Taxonomy
What’s Adapter?

Adapter Motivation
When To Use Adapter?
Adaptor Examples
What’s Proxy?
Proxy Motivation
When To Use Proxy?
Proxy Types
Proxy Example
Pattern Taxonomy
 Structural Patterns

Adapters, Bridges, Facades, and Proxies are
variations on a single theme:

They reduce the coupling between two or more classes.
They introduce an abstract class to enable future
extensions.
They encapsulate complex structures.
What’s Adapter
Convert the Interface of a class into
Target
another interface clients expect. Client uses.
Defines the domain-specific interface that
• Adapter
 Also Known As Wrapper
•


Adapts the interface Adaptee to the Target interface.


Adaptee
Defines an existing interface that needs adapting.



Client
Collaborates with objects conforming to the Target interface.
Adapter Motivation
• Sometimes a toolkit or class library can
not be used because its interface is
incompatible with the interface required by
an application
• We can not change the library interface,
since we may not have its source code
• Even if we did have the source code, we
probably should not change the library for
each domain-specific application
Adapter Example
• Media Player
Client

Uses

VlcPlay er
+ playVlc()
+ playMp4()

MediaPlay er
Implements

Implements

Implements

AudioPlay er
+ play()

Uses

MediaAdapt er
+ play()

Uses
Adv anceMediaPlay er
Implements

Mp4Play er
+ playVlc()
+ playMp4()
Adapter Examples
OracleSt ore

MessageSt at em ent s

Message
Dat abasePersist enceAdapt er

+ long messageId
+ String message
+ Timestamp timestamp
+ String client

I Dat abasePersist ence Implements

Uses
Implements
MessagePersist ence
I MessagePersist ence

Uses

Client

Abst ract Dat abaseSt ore

Uses

Implements

MysqlSt ore
What’s Proxy
• Provide a surrogate or placeholder for
 Proxy

another object to that lets the proxy it.
Maintains a referencecontrol access toaccess
• the real subject. Surrogate
Also Known As
 Subject Interface
Defines the common interface for RealSubject and
proxy so that a Proxy can be used anywhere a
RealSubject is expected.
 RealSubject
Defines the real object that proxy represents.
Proxy Motivation
• There are situations in which a client does
not or can not reference an object directly,
but wants to still interact with the object.
• The proxy object has the same interface as
the target object.
• The proxy holds a reference to the target
object and can forward requests to the target
as required (delegation!).
• In effect, the proxy object has the authority
the act on behalf of the client to interact with
the target object.
Proxy Types
• Virtual Proxy :Allows the creation of a memory intensive object on
•

demand. The object will not be created until it is really needed.
Cache Proxy :Provides temporary storage of the results of expensive
target operations so that multiple clients can share the results.

• Protection (Access) Proxy: Provides different clients with

different levels of access to a target object, we can through
java dynamic proxy API to do.

• Remote Proxy :Provides a reference to an object located in a different
•
•
•
•

address space on the same or different machine. e.g.: RMI & CORBA
Synchronization Proxy :Provides multiple accesses to a target
object.
Copy-On-Write Proxy :Defers copying (cloning) a target object until
required by client actions. Really a form of virtual proxy.
Smart Reference Proxy :Provides additional actions whenever a
target object is referenced such as counting the number of references to the
object.
Firewall Proxy :Protects targets from bad clients (or vice versa).
Virtual Proxy Example
RealI m age

Implements
I m age
Delegates
Uses
Implements
Client

Pr ox y I m age
Cache Proxy Example
Cust om er Dao

Implements
Delegates
I Cust om er Dao
Implements
Cust om er CachedPr ox y

+ Uses

Google Cache
Dynamic Proxy Example
Dynamic Proxy Example
Remote Proxy Example
• Java RMI(Remote Method Invocation)
Synchronization Proxy Example
Table

Implements
I Table

Delegates
Implements
Row Lock TablePr ox y
Q & A

More Related Content

Viewers also liked

Mff715 w1 2_generating_researchideas_fall11
Mff715 w1 2_generating_researchideas_fall11Mff715 w1 2_generating_researchideas_fall11
Mff715 w1 2_generating_researchideas_fall11Rachel Chung
 
Our GBU bioepistemological educational project (BEEMP)
Our GBU bioepistemological educational project (BEEMP)Our GBU bioepistemological educational project (BEEMP)
Our GBU bioepistemological educational project (BEEMP)gbgupresentations
 
Early national literature
Early national literatureEarly national literature
Early national literaturems_faris
 
REDD+ (Transforming Development for Sustainability)
REDD+ (Transforming Development for Sustainability)REDD+ (Transforming Development for Sustainability)
REDD+ (Transforming Development for Sustainability)Tomislav Korman
 
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...Kouluterveyskysely
 
長野市のふるさと納税、小泉提案でようやくここまで来た!!
 長野市のふるさと納税、小泉提案でようやくここまで来た!! 長野市のふるさと納税、小泉提案でようやくここまで来た!!
長野市のふるさと納税、小泉提案でようやくここまで来た!!長野市議会議員小泉一真
 
Pec do Teto de Gastos - o que é?
Pec do Teto de Gastos - o que é?Pec do Teto de Gastos - o que é?
Pec do Teto de Gastos - o que é?Miguel Rosario
 
FUM Belize Friends School
FUM Belize Friends SchoolFUM Belize Friends School
FUM Belize Friends SchoolKelly Kellum
 
Post new korean cinema
Post new korean cinemaPost new korean cinema
Post new korean cinema문정 최
 
Продукция ТРАДО для вашего здоровья
Продукция ТРАДО для вашего здоровьяПродукция ТРАДО для вашего здоровья
Продукция ТРАДО для вашего здоровьяЕлена Шальнова
 
Bio-vision_Kerala quiz 2016
Bio-vision_Kerala quiz 2016Bio-vision_Kerala quiz 2016
Bio-vision_Kerala quiz 2016Subhash Soman
 
Ports For Future Offshore Wind-Event Brochure
Ports For Future Offshore Wind-Event BrochurePorts For Future Offshore Wind-Event Brochure
Ports For Future Offshore Wind-Event Brochuregm330
 
Perfil losa deportiva
Perfil losa deportivaPerfil losa deportiva
Perfil losa deportivaApuhen
 

Viewers also liked (20)

Mff715 w1 2_generating_researchideas_fall11
Mff715 w1 2_generating_researchideas_fall11Mff715 w1 2_generating_researchideas_fall11
Mff715 w1 2_generating_researchideas_fall11
 
Our GBU bioepistemological educational project (BEEMP)
Our GBU bioepistemological educational project (BEEMP)Our GBU bioepistemological educational project (BEEMP)
Our GBU bioepistemological educational project (BEEMP)
 
The Implementation of CSR in European Football by Geoff Walters
The Implementation of CSR in European Football by Geoff WaltersThe Implementation of CSR in European Football by Geoff Walters
The Implementation of CSR in European Football by Geoff Walters
 
SEO再入門
SEO再入門SEO再入門
SEO再入門
 
Early national literature
Early national literatureEarly national literature
Early national literature
 
Guión ingles
Guión inglesGuión ingles
Guión ingles
 
World Renaissance Nov 2011
World Renaissance Nov 2011World Renaissance Nov 2011
World Renaissance Nov 2011
 
REDD+ (Transforming Development for Sustainability)
REDD+ (Transforming Development for Sustainability)REDD+ (Transforming Development for Sustainability)
REDD+ (Transforming Development for Sustainability)
 
Empowering Marketing
Empowering MarketingEmpowering Marketing
Empowering Marketing
 
Arbitros
ArbitrosArbitros
Arbitros
 
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
 
長野市のふるさと納税、小泉提案でようやくここまで来た!!
 長野市のふるさと納税、小泉提案でようやくここまで来た!! 長野市のふるさと納税、小泉提案でようやくここまで来た!!
長野市のふるさと納税、小泉提案でようやくここまで来た!!
 
Pec do Teto de Gastos - o que é?
Pec do Teto de Gastos - o que é?Pec do Teto de Gastos - o que é?
Pec do Teto de Gastos - o que é?
 
C 3
C 3C 3
C 3
 
FUM Belize Friends School
FUM Belize Friends SchoolFUM Belize Friends School
FUM Belize Friends School
 
Post new korean cinema
Post new korean cinemaPost new korean cinema
Post new korean cinema
 
Продукция ТРАДО для вашего здоровья
Продукция ТРАДО для вашего здоровьяПродукция ТРАДО для вашего здоровья
Продукция ТРАДО для вашего здоровья
 
Bio-vision_Kerala quiz 2016
Bio-vision_Kerala quiz 2016Bio-vision_Kerala quiz 2016
Bio-vision_Kerala quiz 2016
 
Ports For Future Offshore Wind-Event Brochure
Ports For Future Offshore Wind-Event BrochurePorts For Future Offshore Wind-Event Brochure
Ports For Future Offshore Wind-Event Brochure
 
Perfil losa deportiva
Perfil losa deportivaPerfil losa deportiva
Perfil losa deportiva
 

Similar to Adapter Poxy Pattern

Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationSabiha M
 
Proxy Design Patterns
Proxy Design PatternsProxy Design Patterns
Proxy Design PatternsZafer Genc
 
Design patterns
Design patternsDesign patterns
Design patternsAlok Guha
 
Linking Data and Actions on the Web
Linking Data and Actions on the WebLinking Data and Actions on the Web
Linking Data and Actions on the WebStuart Charlton
 
Web Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureWeb Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureToru Kawamura
 
Portal and Intranets
Portal and Intranets Portal and Intranets
Portal and Intranets Redar Ismail
 
Hibernate introduction
Hibernate introductionHibernate introduction
Hibernate introductionSagar Verma
 
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2Richard Esplin
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)stanbridge
 
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Sameer Rathoud
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Wen-Tien Chang
 
Design Pattern lecture 4
Design Pattern lecture 4Design Pattern lecture 4
Design Pattern lecture 4Julie Iskander
 
Polaris presentation ioc - code conference
Polaris presentation   ioc - code conferencePolaris presentation   ioc - code conference
Polaris presentation ioc - code conferenceSteven Contos
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns StructuralUMAR ALI
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternNitin Bhide
 

Similar to Adapter Poxy Pattern (20)

Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Proxy Design Patterns
Proxy Design PatternsProxy Design Patterns
Proxy Design Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Linking Data and Actions on the Web
Linking Data and Actions on the WebLinking Data and Actions on the Web
Linking Data and Actions on the Web
 
Web Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureWeb Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the future
 
Adapter Pattern
Adapter PatternAdapter Pattern
Adapter Pattern
 
Portal and Intranets
Portal and Intranets Portal and Intranets
Portal and Intranets
 
Hibernate introduction
Hibernate introductionHibernate introduction
Hibernate introduction
 
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
 
Django course
Django courseDjango course
Django course
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 
Design Pattern lecture 4
Design Pattern lecture 4Design Pattern lecture 4
Design Pattern lecture 4
 
Polaris presentation ioc - code conference
Polaris presentation   ioc - code conferencePolaris presentation   ioc - code conference
Polaris presentation ioc - code conference
 
Microservices
MicroservicesMicroservices
Microservices
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns Structural
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design pattern
 

More from Philip Zhong

Cisco Webex Distributed Framework and Data Store Design
Cisco Webex Distributed Framework and Data Store DesignCisco Webex Distributed Framework and Data Store Design
Cisco Webex Distributed Framework and Data Store DesignPhilip Zhong
 
How to Implement Distributed Data Store
How to Implement Distributed Data Store How to Implement Distributed Data Store
How to Implement Distributed Data Store Philip Zhong
 
MongoDB Knowledge Shareing
MongoDB Knowledge ShareingMongoDB Knowledge Shareing
MongoDB Knowledge ShareingPhilip Zhong
 
How to estimate_oracle_cost
How to estimate_oracle_costHow to estimate_oracle_cost
How to estimate_oracle_costPhilip Zhong
 
Mongo db program_installation_guide
Mongo db program_installation_guideMongo db program_installation_guide
Mongo db program_installation_guidePhilip Zhong
 
Mongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guideMongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guidePhilip Zhong
 
Vitess percona 2012
Vitess percona 2012Vitess percona 2012
Vitess percona 2012Philip Zhong
 
Distributed_Database_System
Distributed_Database_SystemDistributed_Database_System
Distributed_Database_SystemPhilip Zhong
 
Mysql performance tuning
Mysql performance tuningMysql performance tuning
Mysql performance tuningPhilip Zhong
 
Mysql5.1 character set testing
Mysql5.1 character set testingMysql5.1 character set testing
Mysql5.1 character set testingPhilip Zhong
 
How to write_language_compiler
How to write_language_compilerHow to write_language_compiler
How to write_language_compilerPhilip Zhong
 
Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Philip Zhong
 
Mysql handle socket
Mysql handle socketMysql handle socket
Mysql handle socketPhilip Zhong
 
Mysql architecture&parameters
Mysql architecture&parametersMysql architecture&parameters
Mysql architecture&parametersPhilip Zhong
 

More from Philip Zhong (14)

Cisco Webex Distributed Framework and Data Store Design
Cisco Webex Distributed Framework and Data Store DesignCisco Webex Distributed Framework and Data Store Design
Cisco Webex Distributed Framework and Data Store Design
 
How to Implement Distributed Data Store
How to Implement Distributed Data Store How to Implement Distributed Data Store
How to Implement Distributed Data Store
 
MongoDB Knowledge Shareing
MongoDB Knowledge ShareingMongoDB Knowledge Shareing
MongoDB Knowledge Shareing
 
How to estimate_oracle_cost
How to estimate_oracle_costHow to estimate_oracle_cost
How to estimate_oracle_cost
 
Mongo db program_installation_guide
Mongo db program_installation_guideMongo db program_installation_guide
Mongo db program_installation_guide
 
Mongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guideMongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guide
 
Vitess percona 2012
Vitess percona 2012Vitess percona 2012
Vitess percona 2012
 
Distributed_Database_System
Distributed_Database_SystemDistributed_Database_System
Distributed_Database_System
 
Mysql performance tuning
Mysql performance tuningMysql performance tuning
Mysql performance tuning
 
Mysql5.1 character set testing
Mysql5.1 character set testingMysql5.1 character set testing
Mysql5.1 character set testing
 
How to write_language_compiler
How to write_language_compilerHow to write_language_compiler
How to write_language_compiler
 
Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8
 
Mysql handle socket
Mysql handle socketMysql handle socket
Mysql handle socket
 
Mysql architecture&parameters
Mysql architecture&parametersMysql architecture&parameters
Mysql architecture&parameters
 

Recently uploaded

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Adapter Poxy Pattern

  • 1. Adapter & Proxy Pattern Philip zhong Feb, 2014
  • 2. Agenda • • • • • • • • • • Pattern Taxonomy What’s Adapter? Adapter Motivation When To Use Adapter? Adaptor Examples What’s Proxy? Proxy Motivation When To Use Proxy? Proxy Types Proxy Example
  • 3. Pattern Taxonomy  Structural Patterns Adapters, Bridges, Facades, and Proxies are variations on a single theme: They reduce the coupling between two or more classes. They introduce an abstract class to enable future extensions. They encapsulate complex structures.
  • 4. What’s Adapter Convert the Interface of a class into Target another interface clients expect. Client uses. Defines the domain-specific interface that • Adapter  Also Known As Wrapper •  Adapts the interface Adaptee to the Target interface.  Adaptee Defines an existing interface that needs adapting.  Client Collaborates with objects conforming to the Target interface.
  • 5.
  • 6. Adapter Motivation • Sometimes a toolkit or class library can not be used because its interface is incompatible with the interface required by an application • We can not change the library interface, since we may not have its source code • Even if we did have the source code, we probably should not change the library for each domain-specific application
  • 7. Adapter Example • Media Player Client Uses VlcPlay er + playVlc() + playMp4() MediaPlay er Implements Implements Implements AudioPlay er + play() Uses MediaAdapt er + play() Uses Adv anceMediaPlay er Implements Mp4Play er + playVlc() + playMp4()
  • 8. Adapter Examples OracleSt ore MessageSt at em ent s Message Dat abasePersist enceAdapt er + long messageId + String message + Timestamp timestamp + String client I Dat abasePersist ence Implements Uses Implements MessagePersist ence I MessagePersist ence Uses Client Abst ract Dat abaseSt ore Uses Implements MysqlSt ore
  • 9. What’s Proxy • Provide a surrogate or placeholder for  Proxy another object to that lets the proxy it. Maintains a referencecontrol access toaccess • the real subject. Surrogate Also Known As  Subject Interface Defines the common interface for RealSubject and proxy so that a Proxy can be used anywhere a RealSubject is expected.  RealSubject Defines the real object that proxy represents.
  • 10. Proxy Motivation • There are situations in which a client does not or can not reference an object directly, but wants to still interact with the object. • The proxy object has the same interface as the target object. • The proxy holds a reference to the target object and can forward requests to the target as required (delegation!). • In effect, the proxy object has the authority the act on behalf of the client to interact with the target object.
  • 11. Proxy Types • Virtual Proxy :Allows the creation of a memory intensive object on • demand. The object will not be created until it is really needed. Cache Proxy :Provides temporary storage of the results of expensive target operations so that multiple clients can share the results. • Protection (Access) Proxy: Provides different clients with different levels of access to a target object, we can through java dynamic proxy API to do. • Remote Proxy :Provides a reference to an object located in a different • • • • address space on the same or different machine. e.g.: RMI & CORBA Synchronization Proxy :Provides multiple accesses to a target object. Copy-On-Write Proxy :Defers copying (cloning) a target object until required by client actions. Really a form of virtual proxy. Smart Reference Proxy :Provides additional actions whenever a target object is referenced such as counting the number of references to the object. Firewall Proxy :Protects targets from bad clients (or vice versa).
  • 12. Virtual Proxy Example RealI m age Implements I m age Delegates Uses Implements Client Pr ox y I m age
  • 13. Cache Proxy Example Cust om er Dao Implements Delegates I Cust om er Dao Implements Cust om er CachedPr ox y + Uses Google Cache
  • 16. Remote Proxy Example • Java RMI(Remote Method Invocation)
  • 17. Synchronization Proxy Example Table Implements I Table Delegates Implements Row Lock TablePr ox y
  • 18. Q & A