Example of using the Null Object Pattern in C#. More...
Public Member Functions | |
void | Run () |
Executes the example for the Null Object Pattern in C#. | |
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.
|
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().