Design Patterns Java™ Workbook

(Michael S) #1
Chapter 25. Interpreter

Figure 25.3. Command classes generally define themselves using terms that may be
variables, specific machines, or Boolean expressions.

The interpreter classes let you compose programs that control the machine line. Each class
interprets the execute() command in a way that is consistent with the class's name. For
example, the execute() method for StartupCommand is:


public void execute(Context c)
{
Machine m = term.eval(c);
m.startup();
}


For the ForMachines class, execute() is:

Free download pdf