Proxy pattern: Difference between revisions

Content deleted Content added
Bluelinking 1 books for verifiability.) #IABot (v2.1alpha3
PHP: type hinting
Line 66:
 
=== PHP ===
<source lang=PHP"php">
<?php
 
Line 76:
class RealImage implements Image {
 
private string $filename = null;
/**
* Constructor
* @param $filename
*/
public function __construct(string $filename) {
$this->filename = $filename;
$this->loadImageFromDisk();
Line 105:
class ProxyImage implements Image {
 
private Image $image = null;
private string $filename = null;
/**
* Constructor
* @param $filename
*/
public function __construct(string $filename) {
$this->filename = $filename;
}
Line 131:
$image2 = new ProxyImage("HiRes_10MB_Photo2");
 
$image1->displayImage(); // loadingLoading necessary
$image1->displayImage(); // loadingLoading unnecessary
$image2->displayImage(); // loadingLoading necessary
$image2->displayImage(); // loadingLoading unnecessary
$image1->displayImage(); // loadingLoading unnecessary
</source>
 
Line 145:
Displaying HiRes_10MB_Photo2
Displaying HiRes_10MB_Photo2
Displaying HiRes_10MB_Photo1
 
=== C# ===