Provide a placeholder or proxy for another project to access it.
Here are several situations in which the proxy pattern is applicable.
一、A virtual proxy which creates an expensive object on demand.Defer the full cost of an huge object's creation and initialization until we actually need it.We can cache additional information about the real subject so that we can postpone accessing it.
The ImageProxy below is a example of such a proxy.
An document contains expensive images.But opening the document should be fast.So we need avoid creating all expensive objects at once when the document is opened.
Solution: Create expensive objects on demand.When the image is invisible, the description of the image should show in the place of the image.
Interface:Image
Subject:
subjectProxy:
Main:document