LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-12-2012, 07:21 AM   #1
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,732
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Proxy pattern - Applicability & Examples


From here: http://www.oodesign.com/proxy-pattern.html

Quote:
The Proxy design pattern is applicable when there is a need to control access to an Object, as well as when there is a need for a sophisticated reference to an Object. Common Situations where the proxy pattern is applicable are:

Virtual Proxies: delaying the creation and initialization of expensive objects until needed, where the objects are created on demand (For example creating the RealSubject object only when the doSomething method is invoked).

Protection Proxies: where a proxy controls access to RealSubject methods, by giving access to some objects while denying access to others.

Smart References: providing a sophisticated access to certain objects such as tracking the number of references to an object and denying access if a certain number is reached, as well as loading an object from database into memory on demand.
Well, can't Virtual Proxies be created by creating an individual function (other than the constructor) for a new object?

Can't Protection Proxies be created by simply making the function private, and letting only the derived classes get the accesses? OR through the friend class?

Can't Smart References be created by a static member variable which counts the number of objects created?

In which cases should the Proxy method be preferred on the access specifiers and inheritance?

What's the point that I am missing?
 
Old 03-13-2012, 10:04 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,787

Rep: Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084Reputation: 2084
Quote:
Originally Posted by Anisha Kaul View Post
Well, can't Virtual Proxies be created by creating an individual function (other than the constructor) for a new object?
An individual function that must then call a constructor, otherwise where is the object coming from?

Quote:
Can't Protection Proxies be created by simply making the function private, and letting only the derived classes get the accesses? OR through the friend class?
Allowing access only to derived classes could force use of inheritance when it isn't really appropriate. Friend classes are C++ specific (the page you linked to talks in Java).

Quote:
Can't Smart References be created by a static member variable which counts the number of objects created?
Number of references to a particular object != number of objects created.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
squid proxy server configuration & distribution of internet without proxy gaurav_gupta082 Linux From Scratch 2 07-31-2010 11:25 AM
[SOLVED] Help to undestand the applicability of an iPod Nano in Puppy Linux Benny7440 Linux - Software 1 09-21-2009 10:14 AM
matching a pattern in a file & prefixing a word shivarajM Linux - Software 3 05-28-2009 01:14 PM
What applicability of a file /dev/null ukrainet Linux - Newbie 1 12-01-2004 09:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration