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.
Establishing Responsibilities for Problem-Domain Objects Connie’s <strong>Convenience</strong> <strong>Store</strong> 49<br />
Establish responsibilities: “what I do.”<br />
#96. “Establish Transaction Services” Strategy establishing responsibilities /<br />
what I do (pattern players)<br />
• For a transaction, include: calculate for me, rate me, is .<br />
• For a transaction as a collection, include: how many, how much, rank transaction line<br />
items, rank subsequent transactions, calculate over transaction line items, calculate over<br />
subsequent transactions (plus services to enforce business rules across that collection).<br />
• For line items, include: calculate for me, rate me.<br />
So what about for this point-of-sale system? What useful things could a sale do?<br />
How about:<br />
– calculate subtotal for the sale (without tax)<br />
– calculate the discount for the sale<br />
– calculate tax for the sale<br />
– calculate total for the sale (total amount due with tax)<br />
– commit.<br />
Add sale responsibilities to your object model (Figure 1–32):<br />
Sale<br />
date<br />
time<br />
calcSubTotal<br />
calcDiscount<br />
calcTax<br />
calcTotal<br />
commit<br />
1-n<br />
1<br />
SaleLineItem<br />
Session<br />
Figure 1–32: Sale: “what I know; who I know; what I do.”<br />
Sale line item<br />
Establish responsibilities: “what I know.”<br />
In general, what does a transaction line item know? Usually, it knows:<br />
– a date and time, if needed for each line item<br />
– quantity<br />
– tax status (regular, resale, tax-exempt, and the like).<br />
1<br />
n<br />
n<br />
1<br />
Payment