Connie's Convenience Store - About Peter Coad
Connie's Convenience Store - About Peter Coad
Connie's Convenience Store - About Peter Coad
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> 63<br />
The “calcSubtotal” sends a “calcSubtotal” message to a sale line item<br />
object (it repeats this for all of its sale line items).<br />
A sale line item is told to calculate its subtotal.<br />
The “calcSubtotal” service sends a “howMuchForQty” message to an<br />
item object, giving it a quantity and a date. 4<br />
An item object is told to calculate its amount for quantity.<br />
The “howMuchForQty” service invokes the “getPriceForDate”<br />
service, giving it a date.<br />
The “getPriceForDate” service returns a price.<br />
The “howMuchForQty” returns an amount.<br />
The “calcSubtotal” service returns a subtotal.<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.”<br />
Here’s another scenario view convention:<br />
– The “n” on a message arrow indicates that a message may be sent to<br />
some number of objects (Figure 1–40).<br />
So when you see (Figure 1–41):<br />
Sale SaleLineItem<br />
n<br />
Figure 1–41: Sending a message to some number of objects.<br />
4Note that “how much for qty” requires that the quantity be passed to it, as an argument. One<br />
might cry out, “just ask for the value and reduce the argument coupling.” But wait; argument<br />
coupling is not the full story here. Consider the following. Would it be generally useful for an<br />
item to be able to calculate “how much for qty?” Yes. And as the business rules become more<br />
complicated, what object will eventually know enough so it can calculate quantity discounts for<br />
a particular item? An item object (line items never need to know about detail like that).<br />
Very cool.