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 comparison table
Subject have solution have related patterns have references have context have forces have problem has definition have antipatterns is a subtopic of is a kind of is an instance of
design pattern zero or more related design patternsone or more references which indicate who developed or inspired a patterna contextone or more forcesa sentence or two explaining the main difficulty being tackledA pattern useful for the design of softwarezero or more antipatterns - solutions that are inferior or do not work in this context with the reason for their rejection6.1 - Introduction to Patternspattern 
proxy
  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.
several patterns that obtain their power from delegating responsibilities to other classes, hence it uses the Delegation patternone of the Gang of Four patterns
  • There may be a time-delay and a complex mechanism involved in creating instances of heavyweight classes.
  • 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
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.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 neededInstead 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.6.12 - The Proxy Pattern design pattern

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