«interface»
Image
+ display()
RealImage
- 5 MB bitmap
+ display()
ImageProxy
- real: RealImage
+ display()
Same interface, a stand-in
1interface Image { void display(); }2class RealImage implements Image {3 RealImage(String f){ /* load 5 MB bitmap */ }4 public void display(){ /* paint pixels */ }5}6class ImageProxy implements Image {7 private RealImage real; // the controlled subject8 public void display(){ real.display(); }9}
State
RealImageloads 5 MB on create