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

Create successful ePaper yourself

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

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

Scenario: sale calculates its total<br />

Okay. So check it out.<br />

(Pete) How do you calculate the total for a sale?<br />

(Connie) Well, it is not too hard. You have to calculate the subtotal of all of the<br />

line items and add to it the total taxes due on that amount.<br />

A scenario view shows:<br />

– the objects participating in the scenario (across the top of the view)<br />

followed by a time sequence (going down the page) with the following:<br />

– sending service, a message arrow, a receiving service, and arguments<br />

– sending service, a message arrow, a receiving service, and arguments<br />

– sending service, a message arrow, a receiving service, and arguments.<br />

You get the idea.<br />

Please note that there is a leveling of detail here. Scenario views fully expose the<br />

object interactions. Service descriptions present the details of a specific service. So, it’s<br />

time to build a scenario view.<br />

Here’s a good way to do it. Begin with the services within the “recognizer.” Then<br />

expand the scenario, to include interacting objects, too. Consider sale and its messaging<br />

(hey, it’s not very exciting, but it’s a start). Develop a scenario view (Figure 1–39):<br />

Sale<br />

calcTotal<br />

calcSubtotal<br />

calcTax<br />

calcTotal<br />

calcSubtotal<br />

[calcTotal]<br />

calcTax<br />

Scenario: sale calculates its total.<br />

Scenario constraint:<br />

0.1 seconds, 9 out of 10 times,<br />

0.5 seconds max.<br />

sale.calcTotal ( ; total)<br />

sale.calcSubtotal ( ; subtotal)<br />

sale.calcTax ( ; totalTax)<br />

Figure 1–39: The “sale calculates its total” scenario view (round I).<br />

Here’s how to read it:<br />

A specific sale object is told to calculate its total.<br />

The “calcTotal” service invokes the “calcSubtotal” service.<br />

The “calcSubtotal” service returns “subtotal.”<br />

The “calcTotal” service invokes the “calcTax” service.<br />

The “calcTax” service returns “totalTax.”<br />

The “calcTotal” service returns “total.”

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

Saved successfully!

Ooh no, something went wrong!