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.

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

model (and later, in code), a cashier object is an abstraction; it’s not the real thing; it’s a<br />

figment of your imagination.<br />

A cashier object “knows” and “does” things that the system needs to do, pertaining<br />

to the actual cashier. The cashier object and an actual cashier match up perfectly. The<br />

cashier object’s attributes and the actual cashier’s attributes match up, too.<br />

#50. “Select Attributes from Actual Ones” Strategy establishing responsibilities /<br />

what I know (fundamentals)<br />

• This is an aspect of a software object coming to life: “I know selective things that describe<br />

the actual object that I’m an abstraction of.”<br />

• Select the attributes for your software objects, taken from the abundance of the attributes<br />

that could be used to describe a corresponding actual (real-world) object.<br />

• Consider attributes from a broad-sweeping perspective; then work your way into the<br />

specific ones you need. Look at attributes in general, in this domain, and ultimately just<br />

within this system’s responsibilities.<br />

The cashier object’s services and the actual cashier’s services match up, too—but<br />

only if you are developing a simulation system. Otherwise, and that means for most applications,<br />

the services are remarkably different.<br />

Why? Because the services for an object in an object model are those services that<br />

it must fulfill to do its part in achieving the system’s responsibilities. And the services<br />

that an object in an object model is best suited for are the ones which take advantage of<br />

and fully utilize what that object knows and who that object knows. Then an object<br />

comes to life with what it does.<br />

You want to ask the question “Is authorized?” Which automated object should you<br />

turn to? Or you want to send the command “assess performance for a time interval.”<br />

Who does this work for you?<br />

The worker is a cashier object, of course. It’s the one with sufficient knowledge to<br />

coordinate getting these services accomplished. (Otherwise, without this approach, you<br />

end up with a model of data-holding “objects” and function-blob “objects.” Yuck!)<br />

By letting a cashier object take on these services itself, you get lower coupling,<br />

stronger cohesion, and domain-based partitioning of services (not just domain-based<br />

partitioning of attributes). What a deal!<br />

A side note: personification is a vital aspect of “object think.” It’s one of the most<br />

important principles on where to place a service. It helps object modelers strive for distributed<br />

attributes and services, based upon the domain-based partitioning of classes. It<br />

helps people let go of “DFD think” and “ERD think.” 2 Moreover, personification itself is<br />

extremely engaging. Try it out, especially when working out dynamics with scenarios.<br />

What kind of services do you need for cashier?<br />

2 DFD stands for data flow diagram and ERD stands for entity-relationship diagram. These are<br />

both part of design methods that separate data and functions. Yuck!

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

Saved successfully!

Ooh no, something went wrong!