Design Pattern Examples
Overview of object-oriented design patterns
c/Proxy_Exercise.h File Reference

Declaration of the Proxy_Exercise() function as used in the Proxy Pattern. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __PROXY_EXERCISE_H__
 

Functions

void Proxy_Exercise (void)
 Example of using the Proxy design pattern.
 

Detailed Description

Declaration of the Proxy_Exercise() function as used in the Proxy Pattern.

Definition in file c/Proxy_Exercise.h.

Macro Definition Documentation

◆ __PROXY_EXERCISE_H__

#define __PROXY_EXERCISE_H__

Definition at line 9 of file c/Proxy_Exercise.h.

Function Documentation

◆ Proxy_Exercise()

void Proxy_Exercise ( void  )

Example of using the Proxy design pattern.

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 38 of file Proxy_Exercise.c.

References IWorkByProxy::DoWork, DynamicString_Clear(), DynamicString_Initialize(), DynamicString_Set(), GetProxyService(), and DynamicString::string.