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.
40 Connie’s <strong>Convenience</strong> <strong>Store</strong> Establishing Responsibilities for Problem-Domain Objects<br />
#64. “Attribute with Repeating establishing responsibilities /<br />
Values” Strategy what I know (consider and challenge)<br />
• An attribute that may have a number of values?<br />
• Add a new class to your model. Add an object connection. Look for additional attributes<br />
that may apply.<br />
Add a new class, even if it has only one attribute for now.<br />
Why: make the most of problem-domain partitioning; pave the way for<br />
accommodating future change gracefully.<br />
• Example: Item with the attribute UPCs. Add a UPC class. Add an object connection<br />
between an item and its UPCs.<br />
If you potentially could have attributes for each repeating value, then go ahead and<br />
split what’s being described as another class in your model. It’s domain-based partitioning.<br />
Even if the new class has only one attribute, go ahead and add it anyway. As you<br />
find a need for additional attributes and services, you’ll already have this domain-based<br />
partitioning in your model. And that’s a good deal.<br />
Here, UPC is the repeating value. An item in Connie’s <strong>Convenience</strong> <strong>Store</strong> may correspond<br />
to many manufacturer-issued UPCs. Could you have potentially many attributes<br />
for each UPC? Absolutely. A UPC could be described by its code, its bit-map<br />
image, its originator, and its date of first usage.<br />
Right now, within this system’s responsibilities, suppose that all you care about is<br />
the UPC itself. No matter. Go ahead and add a UPC class, with the attribute “upc.”<br />
How about an object connection, too? Yes, you need one. An item knows its UPC<br />
objects. And a UPC object knows its items. Connect item and UPC with an object connection<br />
(Figure 1-26).<br />
Consider price<br />
An item object knows many prices. Hey, you don’t believe it? Check it out with Connie!<br />
(<strong>Peter</strong>) Tell me about the prices of an item.<br />
(Connie) An item has a regular price, beginning on an effective date; we keep track<br />
of past, present, and future regular prices. In addition, an item often has a promotional<br />
price, good from an effective date through an expiration date; we keep track of past,<br />
present, and future promotional prices. We pride ourselves in giving our customers the<br />
best price that applies at the time of purchase.<br />
(<strong>Peter</strong>) Do you plan prices in advance? When would you add them to the system?<br />
(Connie) We plan ahead. And we definitely need to enter the new prices in advance<br />
of their effective dates.<br />
So what does all of this mean to your object model?<br />
An item knows its price objects.<br />
An item knows its regular prices (with price and effective date).<br />
An item knows its promotional prices (with price, effective date, and expiration<br />
date).