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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

What about total? Here’s the strategy:<br />

#66. “Calculable Result” Strategy establishing responsibilities /<br />

what I know (consider and challenge)<br />

• An attribute for holding a calculable result? At first, don’t show it in the object model.<br />

• At some point, you may want to add the attribute. Here’s how:<br />

Add an explicit “get ” service for it.<br />

Specify that service so it:<br />

checks for an attribute value—and returns it, if it has one<br />

otherwise, invokes a calculate service, saves the result, and returns the result<br />

to the sender.<br />

Add an explicit “calculate ” service, too—so you can tell the object to do the<br />

calculation you want it to do.<br />

You could add “total” as an attribute and “get total” as a service. Here, though, keep<br />

it simple and just plan on adding a “calculate total” service to your model.<br />

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

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

#76. “Establish Transaction Object establishing responsibilities /<br />

Connections” Strategy who I know (pattern players)<br />

• For a transaction, include object connections to: participants, transaction line items, a<br />

companion transaction, one that occurs at the same moment in time.<br />

• For a transaction line item, include object connections to: the transaction, a companion<br />

“item description” object, a subsequent transaction line item.<br />

How about this time, for a sale? Well, previously, using patterns, you discovered<br />

who a sale knows:<br />

– session<br />

– payment<br />

– sale line items.<br />

That’s that.

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

Saved successfully!

Ooh no, something went wrong!