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.

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

Payment and kinds of payments<br />

What about payments and the three kinds of payments: cash, check, and charge?<br />

Consider what’s the same, what’s different.<br />

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

What’s the same? Each payment knows its:<br />

– amount paid.<br />

What’s different?<br />

Each cash object knows its:<br />

– cash tendered.<br />

Each check object knows its:<br />

– bank routing number<br />

– account number<br />

– amount tendered<br />

– authorization code.<br />

Each credit object knows its:<br />

– card type<br />

– card number<br />

– expiration date<br />

– authorization code.<br />

Note that two specializations, check and credit, have a common attribute: authorization<br />

code. If these attributes are the same in name and in meaning, and if you can<br />

add a domain-based generalization, add a new generalization to the gen-spec structure.<br />

Here it is:<br />

payment<br />

cash<br />

authorized payment<br />

check<br />

credit.<br />

By doing this, you explicitly express commonality (Figure 1–35). Good show!<br />

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

What’s the same? Each payment knows its corresponding:<br />

– sale.<br />

(And yes, a sale knows about its corresponding payments. Remember, at Connie’s,<br />

a customer may make several payments, with some combination of cash, check, and<br />

charge.)<br />

Okay, what’s different for the kinds of payments? Nothing comes to mind here. Onward!

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

Saved successfully!

Ooh no, something went wrong!