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.
52 Connie’s <strong>Convenience</strong> <strong>Store</strong> Establishing Responsibilities for Problem-Domain Objects<br />
A return line item knows what a sale line item knows, plus:<br />
– return price<br />
– reason code<br />
– sale date<br />
– sale price.<br />
Sounds like a great use of gen-spec. It’s domain-based. Some responsibilities are<br />
the same; some are different.<br />
#67. “Common Attributes” Strategy establishing responsibilities /<br />
what I know (consider and challenge)<br />
• Classes with common attributes?<br />
• If the attributes have the same name and meaning, and if you can find a generalizationspecialization<br />
that makes good sense, then add a generalization class and factor out the<br />
commonality.<br />
#120. “Common Services” Strategy establishing responsibilities /<br />
what I do (consider and challenge)<br />
• Classes with common services?<br />
If the services have the same name and meaning, and if you can find a generalizationspecialization<br />
that makes good sense, then add a generalization class and factor<br />
out whatever commonality you discovered.<br />
If the service name is the same, yet the details of the service are different, then<br />
show the service name in both the generalization and the specialization.<br />
Add a return line item, a specialization of a sale line item (Figure 1–34):<br />
SaleLineItem<br />
quantity<br />
taxStatus<br />
calcSubTotal<br />
ReturnLineItem<br />
salePrice<br />
returnPrice<br />
reasonCode<br />
saleDate<br />
calcSubTotal<br />
1<br />
Figure 1–34: Sale line items and return line items: what’s the same, what’s different.<br />
n<br />
Item