23.07.2012 Views

Design Patterns Explained

Design Patterns Explained

Design Patterns Explained

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

242 Part V • Handling Variations with <strong>Design</strong> <strong>Patterns</strong><br />

New requirement:<br />

add a header<br />

One approach:<br />

use switches in<br />

SalesTicket<br />

Figure 15-1 SalesOrder using SalesTicket.<br />

In the process of writing the application, suppose I get a new<br />

requirement to add header information to the SalesTicket.<br />

How can I handle this new requirement? If I am writing the system to<br />

be used by just one company, it may be easiest simply to add the<br />

control of headers and footers in the SalesTicket class. This is<br />

shown in Figure 15-2.<br />

Figure 15-2 SalesOrder using SalesTicket with different options.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!