Connie's Convenience Store - About Peter Coad
Connie's Convenience Store - About Peter Coad
Connie's Convenience Store - About Peter Coad
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
38 Connie’s <strong>Convenience</strong> <strong>Store</strong> Establishing Responsibilities for Problem-Domain Objects<br />
It also needs to know its transactions—so it can answer questions and perform calculations<br />
across its collection of transactions:<br />
– sales made in the store (zero or more).<br />
It also needs to know some descriptive objects:<br />
– tax categories that apply to the store (zero or more).<br />
(From the other direction, each register, item, cashier, and sale knows a corresponding<br />
store. A sale knows its corresponding store. A tax category knows its corresponding<br />
stores.)<br />
Establish responsibilities: “what I do.”<br />
#95. “Establish Place Services” Strategy establishing responsibilities /<br />
what I do (pattern players)<br />
• For a place, include: calculate for me, rate me, is .<br />
• For a place as a collection, include: how many, how much, rank transactions, rank<br />
contents, rank container line items, calculate over transactions, calculate over contents,<br />
calculate over container line items (plus services to enforce business rules across that<br />
collection).<br />
What useful things can a store object do, to support a point-of-sale system?<br />
A couple of things come to mind. How about:<br />
– get item for UPC<br />
– get cashier for number.<br />
What useful things can a store object do, with calculations across its collection of<br />
objects? It can do plenty. As you investigate the content for each window and report,<br />
you can add services that span “across the collection of things in a store” to store itself.<br />
Add store responsibilities to the model (Figure 1–24):<br />
n<br />
<strong>Store</strong><br />
name<br />
getItemForUPC<br />
getCashierForNumber<br />
Register Item Cashier<br />
n<br />
1 1<br />
1<br />
n n<br />
n<br />
n<br />
Sale<br />
Figure 1–24: <strong>Store</strong>: what I know, who I know, what I do.<br />
1<br />
TaxCategory