proxy pattern
DESCRIPTION
Proxy patternTRANSCRIPT
![Page 1: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/1.jpg)
Design PatternDesign Pattern
Proxy PatternA Structural Pattern
Presented by: Hasnaeen Rizvi Rahman
Copyright © Astha
![Page 2: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/2.jpg)
IntentIntentProvide a surrogate or
placeholder for another object to control access to it.
Copyright © Astha
![Page 3: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/3.jpg)
MotivationMotivationReduce the full cost of creation and
initialization unless we actually need that.
Copyright © Astha
![Page 4: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/4.jpg)
Copyright © Astha
Document EditorDocument Editor
![Page 5: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/5.jpg)
ApplicabilityApplicabilityA remote proxy provides a local
representative for an object in a different address space.
A virtual proxy creates expensive objects on demand.
A protection proxy controls access to the original object. Protection proxies are useful when objects should have different access rights.
A smart reference is a replacement for a bare pointer that performs additional actions when an object is accessed.
Copyright © Astha
![Page 6: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/6.jpg)
StructureStructure
Copyright © Astha
![Page 7: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/7.jpg)
Object DiagramObject Diagram
Copyright © Astha
![Page 8: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/8.jpg)
ParticipantsParticipantsProxy (ImageProxy)
◦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.
Copyright © Astha
![Page 9: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/9.jpg)
ParticipantsParticipants
◦Other responsibilities depend on the kind of proxy. Remote proxies. are responsible for
encoding a request and its arguments and for sending the encoded request to the real subject in a different address space.
Virtual proxies may cache additional information about the real subject so that they can postpone accessing it.
Protection proxies check that the caller has the access permissions required to perform a request.
Copyright © Astha
![Page 10: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/10.jpg)
ParticipantsParticipantsSubject (Graphic)
◦Defines the common interface for RealSubject and Proxy so that a Proxy can be used anywhere a RealSubject is expected.
RealSubject (Image)◦Defines the real object that the
proxy represents.
Copyright © Astha
![Page 11: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/11.jpg)
CollaborationsCollaborationsProxy forwards requests to
RealSubject when appropriate, depending on the kind of proxy.
Copyright © Astha
![Page 12: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/12.jpg)
ConsequencesConsequencesA remote proxy can hide the fact
that an object resides in a different address space.
A virtual proxy can perform optimizations such as creating an object on demand.
Both protection proxies and smart references allow additional housekeeping tasks when an object is accessed.
Copyright © Astha
![Page 13: Proxy pattern](https://reader034.vdocuments.site/reader034/viewer/2022052209/558d4114d8b42ab14f8b4777/html5/thumbnails/13.jpg)
AssignmentAssignment
Copyright © Astha
Some applications allow you to search local-help before searching on-line help. Local help is naturally faster since it resides on your hard drive. On-line help on the other hand is more complete and up-to-date, has undergone greater error-checking based on more users' feedback, refers to more sources and is more up-to-date. Local help is therefore like a proxy for the on-line help. Most times the user will be able to find answers in local-help, but for those really tough problems in specialized situations, on-line help comes to the rescue.
Solve the problem by using proxy design pattern.