Design Patterns Java™ Workbook
Chapter 23. Strategy Figure 23.1. The Customer class relies on other classes for its recommendations, including two off-the-shel ...
Chapter 23. Strategy // if registered, compare to other customers if (isRegistered()) { return (Firework) Rel8.advise(this); } / ...
Chapter 23. Strategy Figure 23.2. Implementations of the Advisor interface provide the strategic recommend() operation, relying ...
Chapter 23. Strategy CHALLENGE 23.2 Fill in the class diagram in Figure 23.3, which shows the recommendation logic refactored in ...
Chapter 23. Strategy String promotedFireworkName = p.getProperty("promote"); if (promotedFireworkName != null) { promoted = Fire ...
Chapter 23. Strategy private Advisor getAdvisor() { if (advisor == null) { if (PromotionAdvisor.singleton.hasItem()) { advisor = ...
Chapter 23. Strategy difference leads to different problems in modeling states and strategies. For example, transitions are impo ...
Chapter 24. Command............................................................................................................. ...
Chapter 24. Command Consider the Visualization2 class from the com.oozinoz.visualization package. This class provides a menu tha ...
Chapter 24. Command CHALLENGE 24.2 Fill in the code for the anonymous subclasses of ActionListener, overriding actionPerformed() ...
Chapter 24. Command package com.oozinoz.util; import junit.framework.*; public class TestCommand extends TestCase { public TestC ...
Chapter 24. Command public void shutDown() { if (inProcess()) { stopProcessing(); markMoldIncomplete(currentMoldID); } usherInpu ...
Chapter 24. Command dischargePaste(); flush(); } Using the previous version of the AsterStarPress class, you created a subclass ...
Chapter 24. Command The COMMAND pattern often names its standard operation execute() or perform(). But nothing limits the operat ...
Chapter 25. Interpreter......................................................................................................... ...
Chapter 25. Interpreter Figure 25.1. An interpreter hierarchy provides for runtime programming of a factory robot. The interpret ...
Chapter 25. Interpreter The Command interpreter design uses a Term hierarchy to contain references to machines, letting you crea ...
Chapter 25. Interpreter "Mixer1201" -> Mixer1201 "StarPress1401" -> StarPress1401 "ShellAssembler1301" -> ShellAssemble ...
Chapter 25. Interpreter Figure 25.3. Command classes generally define themselves using terms that may be variables, specific mac ...
Chapter 25. Interpreter public void execute(Context c) { Iterator i = c.machines.iterator(); while (i.hasNext()) { Machine m = ( ...
«
6
7
8
9
10
11
12
13
14
15
»
Free download pdf