Design Pattern Examples
Overview of object-oriented design patterns
Proxy_Exercise Class Reference

Example of using the Proxy Pattern in C#. More...

Collaboration diagram for Proxy_Exercise:
Collaboration graph

Public Member Functions

void Run ()
 Executes the example for the Proxy Pattern in C#.
 

Detailed Description

Example of using the Proxy Pattern in C#.

The Proxy pattern is used when a large or expensive object cannot be represented directly in the program, typically because the object is in another process or even another system altogether.

In this exercise, a Proxy class implements the same interface as the Real class, making the Proxy class look like the Real class. Calls made on the Proxy class are passed to the Real class where the work is actually done (in this case, a munged string with the text "Real class received 'xxxx'".

The only difference in output here is one additional line for the first call showing the real class being instantiated. The subsequent calls do not show this line.

Definition at line 27 of file Proxy_Exercise.cs.

Member Function Documentation

◆ Run()

void Run ( )
inline

Executes the example for the Proxy Pattern in C#.

Definition at line 33 of file Proxy_Exercise.cs.

References Proxy_Classes_Container.CreateProxy(), and IWorkByProxy.DoWork().

Referenced by Program.Run().


The documentation for this class was generated from the following file: