Known uses reference counting proxies maintain the

This preview shows page 13 - 14 out of 14 pages.

Known Uses: Reference Counting Proxies maintain the reference count inside the object The last proxy to go away is responsible for deleting the object (i.e., when the reference count goes to 0, delete the object) Client A Client B Client C Proxy A Proxy B Proxy C refCount : int = 3 : Real Subject
Image of page 13

Subscribe to view the full document.

Proxy vs. Decorator The Proxy pattern is very similar in structure to the Decorator pattern. Both patterns create a “wrapper” around another object. (Adapter is a third kind of “wrapper”, but is clearly different from Decorator and Proxy because an adapter has a different interface than the wrapped object). Here are some differences between the two patterns: The intents of the patterns are different. Decorator is used to add additional responsibilities to an object (without using inheritance). A Proxy is used to “control access” to an object. Rather than adding functionality, a Proxy might actually prevent access to functionality. Read-only collections, Secure objects Decorators are often organized into chains where each decorator adds a separate responsibility. Proxies are usually not organized into chains (although they could be). A Decorator always stores a reference to the wrapped object; a Proxy may or may not, depending on what it does Distributed objects (proxy never stores direct object reference) Lazy Loading (proxy sometimes stores a direct object reference)
Image of page 14
You've reached the end of this preview.
  • Fall '08
  • Woodfield,S
  • Object-Oriented Programming, Design pattern, Software design patterns, Articles with example Java code, proxy

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern