SlideShare a Scribd company logo
PROXY DESIGN PATTERN
by Zafer GENÇ
Why Proxy Patern ?
• Let’s say , there is some system that is very complicated and we’ll make it
simple,
• And, lets say , we are only interested in some necessary parts , objects vs
not all of them
• And , lets say , every time , instantiating and initializing all objects needs a
lot of time , another words , costs a lot.
WHO DOWE CALL ?
Answer is PROXY
Provide a surrogate or placeholder for another object to control access to it.
Where exactly is the Proxy Pattern used ?
This pattern is recommended when either of the following scenarios occur in
your application:
• The object being represented is external to the system.
• Objects need to be created on demand.
• Access control for the original object is required
• Added functionality is required when an object is accessed.
Typically, you'll want to use a proxy when communication with a third party
is an expensive operation, perhaps over a network.The proxy would allow
you to hold your data until you are ready to commit, and can limit the
amount of times that the communication is called.
The proxy is also useful if you want to decouple actual implementation code
from the access to a particular library.
Proxy is also useful for access to large files, or graphics. By using a proxy,
you can delay loading the resource until you really need the data inside.
Without the concept of proxies, an application could be slow, and appear
non-responsive.
What is like ,the structure of this pattern ?
Proxy
Maintains a reference that lets the proxy access the real subject.
Provides an interface identical to subject's so that a proxy can by substituted
for the real subject.
Controls access to the real subject and may be responsible for creating and
deleting it.
Subject
Defines the common interface for Real Subject and Proxy so that a Proxy can
be used anywhere a Real Subject is expected.
Real Subject
Defines the real object that the proxy represents.
Structure – Object Diagram
Applicable Situations
• Virtual Proxy :
Imagine a situation where there is multiple database call to extract huge size
image. Since this is an expensive operation we can possibly use the proxy pattern
which would create multiple proxies and point to the huge size memory
consuming object for further processing.The real object gets created only when a
client first requests/accesses the object and after that we can just refer to the
proxy to reuse the object.This avoids duplication of the object and hence saving
memory.
• Remote Proxy :
The remote proxy provides a local representation of the object which is
present in the different address location.An example can be providing
interface for remote resources such as web services.
• Protective Proxy :
The protective proxy acts as an authorisation layer to verify if the actual
user has access to appropriate content. An example can be thought about the
proxy server which provides restrictive internet access in office. Only the
websites and contents which are valid will be allowed and the remaining ones
will be blocked.
• Smart reference
A smart reference is a replacement for a bare pointer that performs additional actions when an
object is accessed.
Typical uses include
counting the number of references to the real object so that it can be freed automatically when
there are no more references (also called smart pointers)
loading a persistent object into memory when it's first referenced.
checking that the real object is locked before it's accessed to ensure that no other object can
change it.
Examples …
Virtual Proxy Example
• As mentioned earlier virtual proxy is useful to save expensive memory
resources. Let’s take a scenario where the real image contains a huge size
data which clients needs to access.To save our resources and memory the
implementation will be as below:
• We are going to create an Image interface and concrete classes
implementing the Image interface.
• ProxyImage is a a proxy class to reduce memory footprint of
RealImage object loading.
• ProxyPatternDemo, our demo class, will use ProxyImage to get
an Image object to load and display as it needs.
Protection Proxy Example
• Let’s assume that companyABC starts a new policy that employees will now
be prohibited internet access based on their roles. All external emails
websites will be blocked. ( this is shown as an output like «user have internet
access» or «user dont have internet access» according to the rollNumber) . In
such situation we create InternetAccess interface which consists of
operation grantInternetAccess().
• The RealInternetAccess class which allows of internet access for all.
However to restrict this access we will use ProxyInternetAccess class which
will check user’s role and grant access based on their roles.
Proxy Design Patterns
Proxy Design Patterns

More Related Content

What's hot

Builder design pattern
Builder design patternBuilder design pattern
Proxy Pattern
Proxy PatternProxy Pattern
Proxy Pattern
Hüseyin Ergin
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
Shakil Ahmed
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
sahilrk911
 
Fragments In Android
Fragments In AndroidFragments In Android
Fragments In Android
DivyaKS12
 
Facade pattern
Facade patternFacade pattern
Facade pattern
JAINIK PATEL
 
Design Pattern - Observer Pattern
Design Pattern - Observer PatternDesign Pattern - Observer Pattern
Design Pattern - Observer Pattern
Mudasir Qazi
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
JAINIK PATEL
 
Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)
VishalChavan83
 
DESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy PatternsDESIGN PATTERNS: Strategy Patterns
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
Shakil Ahmed
 
Prototype_pattern
Prototype_patternPrototype_pattern
Prototype_pattern
Iryney Baran
 
Observer design pattern
Observer design patternObserver design pattern
Observer design patternSara Torkey
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
Amit Kabra
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
Shakil Ahmed
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
Shakil Ahmed
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
Adeel Riaz
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
Mudasir Qazi
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 

What's hot (20)

Builder design pattern
Builder design patternBuilder design pattern
Builder design pattern
 
Proxy Pattern
Proxy PatternProxy Pattern
Proxy Pattern
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Fragments In Android
Fragments In AndroidFragments In Android
Fragments In Android
 
Facade pattern
Facade patternFacade pattern
Facade pattern
 
Design Pattern - Observer Pattern
Design Pattern - Observer PatternDesign Pattern - Observer Pattern
Design Pattern - Observer Pattern
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)
 
DESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy PatternsDESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
 
Prototype_pattern
Prototype_patternPrototype_pattern
Prototype_pattern
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 

Viewers also liked

Taller numero 7
Taller  numero 7Taller  numero 7
Taller numero 7
xnoxtrax
 
fuente de poder
fuente de poderfuente de poder
fuente de poder
aldo huarache
 
Dispositivos de interconexion
Dispositivos de interconexionDispositivos de interconexion
Dispositivos de interconexion
AnaCristinaGallego
 
Herramientas e insumos para mantenimiento preventivo
Herramientas e insumos para mantenimiento preventivoHerramientas e insumos para mantenimiento preventivo
Herramientas e insumos para mantenimiento preventivo
angelicacorrea487
 
Semana 01
Semana 01Semana 01
Semana 01
Grupo WSIDesign
 
Herramientas del sistema
Herramientas del sistemaHerramientas del sistema
Herramientas del sistema
Andreafranco99
 
Equipos de interconexion 160608004252
Equipos de interconexion 160608004252Equipos de interconexion 160608004252
Equipos de interconexion 160608004252
tavoramirez980
 
Topologias marcela
Topologias marcelaTopologias marcela
Topologias marcela
bryan1819
 
Técnico En Sistemas
Técnico En SistemasTécnico En Sistemas
Técnico En Sistemas
Andreafranco99
 
Herramientas del sistema
Herramientas del sistema Herramientas del sistema
Herramientas del sistema
CarolinaSepulvedabetancur16
 
3 Years 2 Months Exp. in Dot Net Developer
3 Years 2 Months Exp. in Dot Net Developer3 Years 2 Months Exp. in Dot Net Developer
3 Years 2 Months Exp. in Dot Net DeveloperRahul Shinde
 
Basics of microphone
Basics of microphoneBasics of microphone
Basics of microphone
Samhita Shiledar
 
Computer Applications - The Information and Communication Technology in the w...
Computer Applications - The Information and Communication Technology in the w...Computer Applications - The Information and Communication Technology in the w...
Computer Applications - The Information and Communication Technology in the w...
Faindra Jabbar
 
Tarjeta grafica
Tarjeta graficaTarjeta grafica
Tarjeta grafica
qmaicol3
 

Viewers also liked (17)

March 2016 Issue
March 2016 IssueMarch 2016 Issue
March 2016 Issue
 
Taller numero 7
Taller  numero 7Taller  numero 7
Taller numero 7
 
fuente de poder
fuente de poderfuente de poder
fuente de poder
 
Dispositivos de interconexion
Dispositivos de interconexionDispositivos de interconexion
Dispositivos de interconexion
 
Herramientas e insumos para mantenimiento preventivo
Herramientas e insumos para mantenimiento preventivoHerramientas e insumos para mantenimiento preventivo
Herramientas e insumos para mantenimiento preventivo
 
Wingnut paper #1
Wingnut paper #1Wingnut paper #1
Wingnut paper #1
 
Semana 01
Semana 01Semana 01
Semana 01
 
Herramientas del sistema
Herramientas del sistemaHerramientas del sistema
Herramientas del sistema
 
Equipos de interconexion 160608004252
Equipos de interconexion 160608004252Equipos de interconexion 160608004252
Equipos de interconexion 160608004252
 
Topologias marcela
Topologias marcelaTopologias marcela
Topologias marcela
 
Técnico En Sistemas
Técnico En SistemasTécnico En Sistemas
Técnico En Sistemas
 
Herramientas del sistema
Herramientas del sistema Herramientas del sistema
Herramientas del sistema
 
Creative Brief
Creative BriefCreative Brief
Creative Brief
 
3 Years 2 Months Exp. in Dot Net Developer
3 Years 2 Months Exp. in Dot Net Developer3 Years 2 Months Exp. in Dot Net Developer
3 Years 2 Months Exp. in Dot Net Developer
 
Basics of microphone
Basics of microphoneBasics of microphone
Basics of microphone
 
Computer Applications - The Information and Communication Technology in the w...
Computer Applications - The Information and Communication Technology in the w...Computer Applications - The Information and Communication Technology in the w...
Computer Applications - The Information and Communication Technology in the w...
 
Tarjeta grafica
Tarjeta graficaTarjeta grafica
Tarjeta grafica
 

Similar to Proxy Design Patterns

Gang of four Proxy Design Pattern
 Gang of four Proxy Design Pattern Gang of four Proxy Design Pattern
Gang of four Proxy Design PatternMainak Goswami
 
Introduction-to-Design-Patternsssss.pptx
Introduction-to-Design-Patternsssss.pptxIntroduction-to-Design-Patternsssss.pptx
Introduction-to-Design-Patternsssss.pptx
LightOFC1
 
Adapter Poxy Pattern
Adapter Poxy PatternAdapter Poxy Pattern
Adapter Poxy PatternPhilip Zhong
 
TechTalk: Advanced Practices for Visual Test Automation
TechTalk: Advanced Practices for Visual Test AutomationTechTalk: Advanced Practices for Visual Test Automation
TechTalk: Advanced Practices for Visual Test Automation
Lizzy Guido (she/her)
 
Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02
Jagath Bandara Senanayaka
 
Automate Design Patterns
Automate Design PatternsAutomate Design Patterns
Automate Design Patterns
Iulian Ilie-Némedi
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
Michel Bruchet
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
Michel Bruchet
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
Sabiha M
 
Design patterns through java
Design patterns through javaDesign patterns through java
Design patterns through java
Aditya Bhuyan
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
Rahul Malhotra
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
Matthias Noback
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Ahmad Hussein
 
Design_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.pptDesign_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.ppt
C Meenakshi Meyyappan
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
Muhammad Sajid
 
1 croreprojects dotnet ppt
1 croreprojects dotnet ppt1 croreprojects dotnet ppt
1 croreprojects dotnet ppt
Kumar Dlk
 
Tutor-marked assignment TMA 03 Printable page generated Saturd.docx
Tutor-marked assignment TMA 03 Printable page generated Saturd.docxTutor-marked assignment TMA 03 Printable page generated Saturd.docx
Tutor-marked assignment TMA 03 Printable page generated Saturd.docx
juliennehar
 
B04010 01 0917
B04010 01 0917B04010 01 0917
B04010 01 0917IJMER
 
Monk objects
Monk objectsMonk objects
Monk objects
SKI Groups
 
Multi tenancy - Wining formula for a PaaS
Multi tenancy - Wining formula for a PaaSMulti tenancy - Wining formula for a PaaS
Multi tenancy - Wining formula for a PaaSWSO2
 

Similar to Proxy Design Patterns (20)

Gang of four Proxy Design Pattern
 Gang of four Proxy Design Pattern Gang of four Proxy Design Pattern
Gang of four Proxy Design Pattern
 
Introduction-to-Design-Patternsssss.pptx
Introduction-to-Design-Patternsssss.pptxIntroduction-to-Design-Patternsssss.pptx
Introduction-to-Design-Patternsssss.pptx
 
Adapter Poxy Pattern
Adapter Poxy PatternAdapter Poxy Pattern
Adapter Poxy Pattern
 
TechTalk: Advanced Practices for Visual Test Automation
TechTalk: Advanced Practices for Visual Test AutomationTechTalk: Advanced Practices for Visual Test Automation
TechTalk: Advanced Practices for Visual Test Automation
 
Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02
 
Automate Design Patterns
Automate Design PatternsAutomate Design Patterns
Automate Design Patterns
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Design patterns through java
Design patterns through javaDesign patterns through java
Design patterns through java
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.pptDesign_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.ppt
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
1 croreprojects dotnet ppt
1 croreprojects dotnet ppt1 croreprojects dotnet ppt
1 croreprojects dotnet ppt
 
Tutor-marked assignment TMA 03 Printable page generated Saturd.docx
Tutor-marked assignment TMA 03 Printable page generated Saturd.docxTutor-marked assignment TMA 03 Printable page generated Saturd.docx
Tutor-marked assignment TMA 03 Printable page generated Saturd.docx
 
B04010 01 0917
B04010 01 0917B04010 01 0917
B04010 01 0917
 
Monk objects
Monk objectsMonk objects
Monk objects
 
Multi tenancy - Wining formula for a PaaS
Multi tenancy - Wining formula for a PaaSMulti tenancy - Wining formula for a PaaS
Multi tenancy - Wining formula for a PaaS
 

Recently uploaded

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
nikitacareer3
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
iemerc2024
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
obonagu
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 

Recently uploaded (20)

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 

Proxy Design Patterns

  • 2. Why Proxy Patern ? • Let’s say , there is some system that is very complicated and we’ll make it simple, • And, lets say , we are only interested in some necessary parts , objects vs not all of them • And , lets say , every time , instantiating and initializing all objects needs a lot of time , another words , costs a lot. WHO DOWE CALL ?
  • 3. Answer is PROXY Provide a surrogate or placeholder for another object to control access to it.
  • 4. Where exactly is the Proxy Pattern used ? This pattern is recommended when either of the following scenarios occur in your application: • The object being represented is external to the system. • Objects need to be created on demand. • Access control for the original object is required • Added functionality is required when an object is accessed.
  • 5. Typically, you'll want to use a proxy when communication with a third party is an expensive operation, perhaps over a network.The proxy would allow you to hold your data until you are ready to commit, and can limit the amount of times that the communication is called. The proxy is also useful if you want to decouple actual implementation code from the access to a particular library. Proxy is also useful for access to large files, or graphics. By using a proxy, you can delay loading the resource until you really need the data inside. Without the concept of proxies, an application could be slow, and appear non-responsive.
  • 6. What is like ,the structure of this pattern ?
  • 7. Proxy Maintains a reference that lets the proxy access the real subject. Provides an interface identical to subject's so that a proxy can by substituted for the real subject. Controls access to the real subject and may be responsible for creating and deleting it.
  • 8. Subject Defines the common interface for Real Subject and Proxy so that a Proxy can be used anywhere a Real Subject is expected. Real Subject Defines the real object that the proxy represents.
  • 10. Applicable Situations • Virtual Proxy : Imagine a situation where there is multiple database call to extract huge size image. Since this is an expensive operation we can possibly use the proxy pattern which would create multiple proxies and point to the huge size memory consuming object for further processing.The real object gets created only when a client first requests/accesses the object and after that we can just refer to the proxy to reuse the object.This avoids duplication of the object and hence saving memory.
  • 11. • Remote Proxy : The remote proxy provides a local representation of the object which is present in the different address location.An example can be providing interface for remote resources such as web services. • Protective Proxy : The protective proxy acts as an authorisation layer to verify if the actual user has access to appropriate content. An example can be thought about the proxy server which provides restrictive internet access in office. Only the websites and contents which are valid will be allowed and the remaining ones will be blocked.
  • 12. • Smart reference A smart reference is a replacement for a bare pointer that performs additional actions when an object is accessed. Typical uses include counting the number of references to the real object so that it can be freed automatically when there are no more references (also called smart pointers) loading a persistent object into memory when it's first referenced. checking that the real object is locked before it's accessed to ensure that no other object can change it.
  • 14. Virtual Proxy Example • As mentioned earlier virtual proxy is useful to save expensive memory resources. Let’s take a scenario where the real image contains a huge size data which clients needs to access.To save our resources and memory the implementation will be as below: • We are going to create an Image interface and concrete classes implementing the Image interface. • ProxyImage is a a proxy class to reduce memory footprint of RealImage object loading. • ProxyPatternDemo, our demo class, will use ProxyImage to get an Image object to load and display as it needs.
  • 15.
  • 16. Protection Proxy Example • Let’s assume that companyABC starts a new policy that employees will now be prohibited internet access based on their roles. All external emails websites will be blocked. ( this is shown as an output like «user have internet access» or «user dont have internet access» according to the rollNumber) . In such situation we create InternetAccess interface which consists of operation grantInternetAccess(). • The RealInternetAccess class which allows of internet access for all. However to restrict this access we will use ProxyInternetAccess class which will check user’s role and grant access based on their roles.