VirtualProxy

Origin: Larman 98
Reason: Delay the instantiation of an object (expensive to instantiated) until the object is needed.
Synopsis: Create an object, the VirtualProxy, that allows clients indirect access to the expensive-to-create object, and hides from clients whether the expensive-to-create object exists.
Example: A large applet executes several well-separated components. A typical execution of the applet requires some, but not all, these components.
Solution:
Client Class that needs the services of the Service class. The Client does not access the Service class directly, thus it is insensitive to whether the Service class is loaded.
Service Class providing services to the Client. Supposedly, the Service class is expensive to load and/or instantiate.
ServiceIF Interface implemented by both the Service and the ServiceProxy classes.
ServiceProxy Class that provides services to the Client through the Service class. It loads and/or instantiates this class only when needed.
See also: Proxy (a generalization of this pattern)
DynamicLinkage (option for dynamically loading a class)