Content deleted Content added
No edit summary |
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags |
||
Line 66:
=== PHP ===
<
<?php
Line 134:
$image2->displayImage(); // Loading unnecessary
$image1->displayImage(); // Loading unnecessary
</syntaxhighlight>
The program's output is:
Line 146:
=== C# ===
<
interface ICar
{
Line 201:
car.DriveCar();
}
</syntaxhighlight>
Output
Sorry, the driver is too young to drive.
Line 213:
=== C++ ===
<
#include <iostream>
#include <memory>
Line 253:
car->DriveCar();
}
</syntaxhighlight>
=== Crystal ===
<
abstract class AbstractCar
abstract def drive
Line 299:
car = ProxyCar.new(driver)
car.drive
</syntaxhighlight>
Output
Line 306:
=== Delphi / Object Pascal ===
<
// Proxy Design pattern
unit DesignPattern.Proxy;
Line 404:
end.
</syntaxhighlight>
Usage
<
program Project1;
{$APPTYPE Console}
Line 416:
TProxyCar.New(TDriver.New(25)).DriveCar;
end.
</syntaxhighlight>
Output
Line 429:
The proxy class <tt>ProxyImage</tt> is running on another system than the real image class itself and can represent the real image <tt>RealImage</tt> over there. The image information is accessed from the disk. Using the proxy pattern, the code of the <tt>ProxyImage</tt> avoids multiple loading of the image, accessing it from the other system in a memory-saving manner. The lazy loading demonstrated in this example is not part of the proxy pattern, but is merely an advantage made possible by the use of the proxy.
<
interface Image {
public void displayImage();
Line 501:
}
}
</syntaxhighlight>
The program's output is:
Line 513:
===Python===
<
"""
Proxy pattern example.
Line 560:
car = ProxyCar(driver)
car.drive()
</syntaxhighlight>
===Rust===
<
trait ICar {
fn drive(&self);
Line 624:
}
}
</syntaxhighlight>
==See also==
* [[Composite pattern]]
|