design pattern | | zero or more related design patterns | one or more references which indicate who developed or inspired a pattern | a context | one or more forces | a sentence or two explaining the main difficulty being tackled | A pattern useful for the design of software | zero or more antipatterns - solutions that are inferior or do not work in this context with the reason for their rejection | 6.1 - Introduction to Patterns | pattern | |
proxy | - Create a simpler version of the «HeavyWeight» class.
- We will call this simpler version a «Proxy».
- 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 pattern | one 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 needed | 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. | 6.12 - The Proxy Pattern | | design pattern |