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.

50 Connie’s <strong>Convenience</strong> <strong>Store</strong> Establishing Responsibilities for Problem-Domain Objects<br />

How about in this case? What does a sale line item know?<br />

– quantity<br />

– tax status.<br />

Establish responsibilities: “who I know.”<br />

In general, who does a transaction line item know?<br />

It knows:<br />

– an item (or some other tangible thing), the one for which the transaction<br />

line item knows a quantity value<br />

– a subsequent line item.<br />

How about in this case? Who does a sale line item know?<br />

– an item.<br />

A sale line item could know a return line item. Hold onto that thought. You’ll get a<br />

chance to pursue it in a few pages.<br />

Meanwhile . . .<br />

A sale line item knows:<br />

– an item<br />

– a sale.<br />

(And each sale and item knows some number of sale line items.)<br />

Establish responsibilities: “what I do.”<br />

Now turn to the active side of a sale line item. What useful things could a sale line item<br />

do? How about:<br />

– calculate subtotal (for this sale line item).<br />

Add sale line-item responsibilities to your model (Figure 1–33):<br />

Sale<br />

1-n<br />

1<br />

SaleLineItem<br />

quantity<br />

taxStatus<br />

calcSubTotal<br />

1<br />

Figure 1–33: Sale line item: “what I know; who I know; what I do.”<br />

On describing each service<br />

A good service name goes a long way toward describing what a service is all about.<br />

At some point along the way, you can add some service descriptions, too. After all,<br />

you and others need to know what you really intend for each service.<br />

n<br />

Item

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

Saved successfully!

Ooh no, something went wrong!