• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Question on Proxy pattern..

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could someone tell what a proxy pattern is used for? I know a proxy
object represents another object.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two general reasons to use it. One is in a distributed system. When the actual object resides on another machine, and you want to invoke a method on it, the proxy is the local object that receives the method invocation and then marshalls the parameters and sends them across the network, then unmarshalls the result when it comes back. The second general use is in database ORM systems when you have a deeply nested object and you choose to represent a contained object as a proxy that only contains the foreign key -- you would retrieve and instantiate the actual object only when it is referenced through a method call.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The virtual proxy (in GoF terms) variant is also quite common.
A virtual proxy allows the initialization cost of an 'expensive' (in terms of memoery usage, for example) object to be defered up to the moment it becomes necessary for the actual object to be fully initialized - creation on demand.

Edit: I just realized that Kyle Brown already described this use, though it's not limited to ORM solutions.
[ July 24, 2008: Message edited by: Jelle Klap ]
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic