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.

Applying Patterns: Select and Organize Problem-Domain Objects Connie’s <strong>Convenience</strong> <strong>Store</strong> 25<br />

A store, as content<br />

Consider a store as content, then as a container.<br />

A store is a part of a chain. “Chain” would be interesting, especially if you wanted<br />

to do a calculation across a collection of stores. Not this time, however.<br />

A store, as a container<br />

A store is a domain-based container.<br />

Think of the store as a large container. What does it contain? Look inside. A store<br />

contains registers, items, cashiers (Figure 1–14).<br />

<strong>Store</strong> is a domain-based container. Domain-based containers are a convenient place<br />

for expressing responsibilities across a collection of other domain objects, ones that are<br />

not already taken care of by some other collection. Eventually, you may want add to the<br />

kinds of objects that a store object knows.<br />

Figure 1–14: <strong>Store</strong>–register, item, cashier.<br />

Note that a store object knows its registers, items, and cashiers. That makes sense.<br />

On notation: in each case, the triangle points from a part to a whole.<br />

Transaction–transaction line item<br />

A sale is a transaction.<br />

Nearly all transaction objects have corresponding transaction line items.<br />

<strong>Store</strong><br />

n n<br />

Register Item<br />

Cashier<br />

n<br />

1 1<br />

1

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

Saved successfully!

Ooh no, something went wrong!