lecture 39: when to use a proxy
DESCRIPTION
Computer Science 313 – Advanced Programming Topics. Lecture 39: When to Use A Proxy. Why Do We Use Proxy Pattern?. Discussed word proxy in Wednesday's lecture When and why would we ever use a proxy?. Real-World Uses of Proxy. Real-World Uses of Proxy. Real-World Uses of Proxy. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/1.jpg)
LECTURE 39:WHEN TO USE A PROXY
Computer Science 313 – Advanced Programming Topics
![Page 2: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/2.jpg)
Why Do We Use Proxy Pattern? Discussed word proxy in
Wednesday's lecture
When and why would we ever use a proxy?
![Page 3: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/3.jpg)
Real-World Uses of Proxy
![Page 4: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/4.jpg)
Real-World Uses of Proxy
![Page 5: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/5.jpg)
Real-World Uses of Proxy
![Page 6: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/6.jpg)
Real-World Uses of Proxy
![Page 7: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/7.jpg)
Why We Use Proxy
Add level of indirection before real subject Continue actions, but protect subject
from harm Create plausible deniability – "But it
wasn't me!" Get tasks done, but eliminate need to be
local Improve performance by using saved
results Same design needs met using Proxy
Pattern In all cases, proxy appears identical to
real subject Proxy acts first then lets subject do the
real work Real subject stays hidden – client does
not know
![Page 8: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/8.jpg)
Proxy versus… Adapter
Proxy Pattern Adapter Pattern
![Page 9: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/9.jpg)
Proxy versus… Adapter
Proxy Pattern Adapter Pattern Client only knows of
Proxy Uses interface client
needs Subject does all work
Interface identical to the real subjects
Does not change each calls' parameters & return value
Cannot access real subject
Client only knows of Adapter
Uses interface client needs
Adaptee(s) does all work
Interface differs with that of adaptee(s)
Modifies, adds or removes parameters & return value
Can access real subject
![Page 10: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/10.jpg)
Proxy versus… Composite
Proxy Pattern Composite Pattern
![Page 11: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/11.jpg)
Proxy versus… Composite
Proxy Pattern Composite Pattern Structural pattern Common interface
defined One of GoF's patterns
Only one subject used
Proxy acts as a gatekeeper
Structural pattern Common interface
defined One of GoF's patterns
Many leaves can be used
Composite collects leaves
![Page 12: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/12.jpg)
Proxy versus… Decorator
Proxy Pattern Decorator Pattern
![Page 13: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/13.jpg)
Proxy versus… Decorator
Proxy Pattern Decorator Pattern Client thinks it has
subject Hides subject from
others Proxy can intercept
call
One proxy per pattern Does not add or
modify basic functionality
Client thinks has concept
Hides concept from others
Decorator can intercept call
Many decorators per pattern
Adds or modifies concept's basic functionality
![Page 14: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/14.jpg)
Proxy versus… Observer
Proxy Pattern Observer Pattern
![Page 15: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/15.jpg)
Proxy versus… Observer
Proxy Pattern Observer Pattern
![Page 16: Lecture 39: When to Use A Proxy](https://reader035.vdocuments.us/reader035/viewer/2022062305/568166fb550346895ddb5f5a/html5/thumbnails/16.jpg)
For Next Class
Last lab due “Friday”; submit until final exam time Start now == more committing acts involving
carrots Finish reading on our last design pattern
Lots of interesting code on Wednesday Will be presenting many cool & useful hacks Follow the white rabbit – they have tricks &
carrots
----------censored----------