20.02.2013 Views

Connie's Convenience Store - About Peter Coad

Connie's Convenience Store - About Peter Coad

Connie's Convenience Store - About Peter Coad

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

64 Connie’s <strong>Convenience</strong> <strong>Store</strong> Working Out Problem-Domain Dynamics with Scenarios<br />

What’s being expressed is this (Figure 1–42):<br />

Sale SaleLineItem<br />

Figure 1–42: Picturing messages to some number of objects in a class.<br />

So far, so good.<br />

What’s next? What other sale service needs your attention? It’s time to calculate tax.<br />

(<strong>Peter</strong>) How do you calculate the tax for a sale?<br />

(Connie) Actually, tax collection varies from country to country. Here’s what we do<br />

in the States. We calculate the subtotal for each tax category. Then we apply the tax rate<br />

to each tax category. Finally, we add up the results, to get the tax for a specific sale.<br />

(<strong>Peter</strong>) Yuck!<br />

Tax matters always complicate things. Welcome to the real world.<br />

Sketch it out:<br />

A sale asks a store for its tax categories.<br />

A sale tells a sale line item to calculate its tax for a specified tax category.<br />

A sale line item tells its item to calculate its amount in a tax category.<br />

An item gets its price for that date.<br />

A sale asks a tax category for its rate.<br />

You’ve got some new players: tax category and store (store acts as a collection of<br />

tax categories).<br />

Expand the scenario view accordingly (Figure 1–43):

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

Saved successfully!

Ooh no, something went wrong!