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

Example of using the Null Object Pattern in C#. More...

Collaboration diagram for NullObject_Exercise:
Collaboration graph

Public Member Functions

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

Detailed Description

Example of using the Null Object Pattern in C#.

The Null Object pattern is where an object or function acts as a stand-in for real commands but otherwise does nothing.

In this exercise, movement commands are presented as characters in a string, with the characters 'u', 'd', 'l', and 'r' representing the moves "up", "down", "left", and "right", respectively. To keep the processing of this string simple, all other characters in the string are assigned a Null Object ("Do Nothing") version of the move command.

This example displays the commands after parsing and then "executes" commands, which consists of printing the commands out.

This example highlights the Null Object pattern while utilizing the Command and Interpreter patterns.

Definition at line 29 of file NullObject_Exercise.cs.

Member Function Documentation

◆ Run()

void Run ( )
inline

Executes the example for the Null Object Pattern in C#.

Definition at line 35 of file NullObject_Exercise.cs.

References MoveProcessor.ExecuteMoveList(), and MoveProcessor.ShowMoveList().

Referenced by Program.Run().


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