Object Oriented Software Engineering   View all facts   Glossary   Help
subject > pattern > design pattern > proxy
Next design patternread-only interface    Updesign pattern    Previous design patternplayer-role   

proxy
subjectfact 
proxyhas definition A pattern found in which a lightweight object stands in place of a heavyweight object that has the same interface. It transparently loads the heavyweight object when needed2001-08-30 14:57:11.0
has antipatterns Instead of using proxy objects, beginner designers often scatter complex code around their application to load objects from databases. A strategy that only works for very small systems is to load the whole database into memory when the program starts.2001-08-30 14:57:11.0
has context
  • There may be a time-delay and a complex mechanism involved in creating instances of heavyweight classes.
2001-08-30 14:57:11.0
has forces
  • You want all the objects in a domain model to be available for programs to use when they execute a system's various responsibilities
  • It is important for many objects to persist from run to run of the same program
  • in a large system it would be impractical for all the objects to be loaded into memory whenever a program starts
  • It would be ideal to be able to program the application as if all the objects were located in memory
2001-08-30 14:57:11.0
has problem How can you reduce the need to create instances of a heavyweight class? In particular, how can you reduce the need to load large numbers of them from a database or server, when not all of them will be needed? A related problem is this: If you load one object from a database or server, how can you avoid loading all the other objects that are linked to it.2001-08-30 14:57:11.0
has references one of the Gang of Four patterns2001-08-30 14:57:11.0
has related patterns several patterns that obtain their power from delegating responsibilities to other classes, hence it uses the Delegation pattern2001-08-30 14:57:11.0
has solution
  1. Create a simpler version of the «HeavyWeight» class.
  2. We will call this simpler version a «Proxy».
  3. The «Proxy» has the same interface as the «HeavyWeight», so programmers can declare variables without caring whether a «Proxy» or its «HeavyWeight» version will be put in the variable.
2001-08-30 14:57:11.0
is a subtopic of 6.12 - The Proxy Pattern2001-08-30 14:57:11.0
is an instance of design pattern2001-08-30 14:57:11.0
design patternhas name2001-08-30 14:55:16.0
should be illustrated using a simple diagram2001-08-30 14:55:16.0
should be written using a narrative writing style2001-08-30 14:55:16.0
patternshould be as general as possible2001-08-30 14:56:56.0
should be described in an easy-to-understand form so that people can determine when and how to use it2001-08-30 14:56:56.0
should contain a solution that has been proven to effectively solve the problem in the indicated context2001-08-30 14:56:56.0

Next design patternread-only interface    Updesign pattern    Previous design patternplayer-role