01.01.2015 Views

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

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.

Session 22—Modeling the Extended Features of the Statechart 231<br />

Send event<br />

You learned the send event in Session 21. But send events are common enough that it is<br />

worth presenting them again briefly in this context. Objects interact to get work done. In<br />

the Statechart diagram, you’re modeling why and when an object would perform such interactions.<br />

A send event models the fact that an object tells another object what to do. A send<br />

event may be a response to a transition event or an internal event.<br />

Figure 22-6 models a send event as part of the action required by a transition event.<br />

When the shipped(carrier, datetime) event occurs, two actions are triggered with the transition:<br />

setShipped() to change the state; and a message to the Customer object to generate a<br />

notification to the real customer that her Order has been shipped.<br />

Packaged<br />

after 3 days/upgradeShippingPriority()<br />

shipped(carrier, datetime)/<br />

setShipped(),<br />

Customer.notify(Shipment, Order)<br />

Shipped<br />

Figure 22-6<br />

Send event Customer.notify(Shipment, Order)<br />

Guard conditions as events<br />

A guard condition may actually be used by itself as a triggering event. It simply implies<br />

that the object is watching for a condition to be satisfied. For example, your bank account<br />

monitors its balance as the deposits and withdrawals are computed. If, at any time, the balance<br />

drops below zero, the account jumps at the opportunity to fire off an overdraft charge.<br />

Modeling Superstates and Substates<br />

Modeling often requires different views of a problem. High-level views simplify the model.<br />

Low-level views focus on details of a problem. The <strong>UML</strong> Statechart diagram supports the concept<br />

of nested states, allowing both high- and low-level views of object behavior and states.<br />

A superstate is simply a state that is expanded to show more detail. The state rounded<br />

rectangle icon is expanded and the details are represented as one or more Statecharts<br />

within the superstate. The name of the state is placed at the top. Superstates represent a<br />

high-level view of a complex situation. They allow you to focus on the bigger, more general<br />

problem without getting lost in the details. The substates are placed within the expanded<br />

superstate.

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

Saved successfully!

Ooh no, something went wrong!