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.

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

So what should you add to your model?<br />

Add a price class, with the attributes:<br />

– price<br />

– effective date.<br />

Add a specialization class, promo price, with the attributes:<br />

– price<br />

– effective date<br />

– expiration date.<br />

But wait! A specialization class inherits the attributes, connections, services, and<br />

messages that apply to its generalization class. You see, a gen-spec structure communicates<br />

“what’s the same; what’s different.”<br />

What’s the same:<br />

– price<br />

– effective date.<br />

What’s different:<br />

– expiration date.<br />

Add it to your model.<br />

What about object connections? An item knows its price objects. And a price object<br />

knows its item. So connect item and price with an object connection (Figure 1–26):<br />

upc<br />

UPC<br />

1 n<br />

Item<br />

number<br />

description<br />

taxable<br />

n 1<br />

price<br />

effectiveDate<br />

Figure 1–26: Discovering additional objects and responsibilities.<br />

On describing each attribute<br />

At some point along the way, you might add some descriptive information about each<br />

attribute.<br />

First things first, however. Pick good attribute names, ones that communicate exceedingly<br />

well. A well-chosen name is far more helpful than an abundance of descriptive<br />

words. (Hey! And that means if you need a long-winded attribute description, you<br />

should find a better attribute name.)<br />

Nevertheless, you may want to add attribute descriptions, more fully communicating<br />

what each attribute is all about.<br />

Price<br />

PromoPrice<br />

expirationDate

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

Saved successfully!

Ooh no, something went wrong!