UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory UML Weekend Crash Course™ - To Parent Directory

crnarupa.singidunum.ac.rs
from crnarupa.singidunum.ac.rs More from this publisher
01.01.2015 Views

Session 21—Applying the Basic Statechart to the Case Study 219 The same simplification may be used for actions associated with events that leave a state. These are called exit actions and are modeled in the same manner as entry actions. If you refer back to Figure 21-1, you will see two events leaving the Placed state. Both events have the same associated action, issueCustomerStmt(). Figure 21-3 shows the exit/action(s) notation added to the internal transitions compartment of the Placed state and the actions removed from the event arrows. Compare Figure 21-1 with 21-3 to appreciate the simplification. receive pmt Order is filled Filled Tentative Placed entry/issueConf() exit/issueCustomerStmt() authorize override cancel Cancelled Figure 21-3 Consolidating the exit actions Entry and exit action notations provide a nice simplification for the Statechart diagram. Just remember that they may only be used when the action takes place every time you enter (for entry actions) or every time you exit (for exit actions) the state. If there is even one exception, the notation may not be used for that action. Defining Send Events Figure 21-4 introduces the send event. A send event is used when the object in the Statechart diagram needs to communicate with another object. On a Statechart diagram, the source of the incoming events is not shown because the same event may come from any number of other objects and the response must be the same. But an outgoing event must define the receiving object whether it is only one object or a broadcast to many objects. It works in the same way you use your phone. You can receive calls without knowing who is calling. But you cannot place a call without the number you want to call.

220 Sunday Morning receive pmt Order is filled Filled Tentative Placed entry/issueConf() exit/CustomerStmt.issue() authorize override cancel Cancelled Figure 21-4 Modeling an action invoked on another object In the example in Figure 21-3, when the Order is cancelled, the Order is supposed to issue a customer statement. But the customer statement is another object that takes care of issuing itself. The Order just needs to tell it that it’s time to do so. All the actions modeled so far were actions on the same object. To show that the action is invoked on a different object, simply provide the object name followed by a period before the action expression. This is often referred to as the dot notation. See the exit action notation in Figure 21-4 where the issue() action is now being sent to the CustomerStmt object. Order of Events With all these events, you could end up with a tangled mess of event actions, entry actions, exit actions, and activities. So how do you process all this behavior in a sane fashion When an event occurs, the order of execution runs like this: 1. If an activity is in progress in the current state, interrupt it (gracefully if possible). 2. Execute the exit: action(s). 3. Execute the actions associated with the event that started it all. 4. Execute the entry: action(s) of the new state. 5. Execute the activity or activities of the new state.

Session 21—Applying the Basic Statechart to the Case Study 219<br />

The same simplification may be used for actions associated with events that leave a state.<br />

These are called exit actions and are modeled in the same manner as entry actions. If you refer<br />

back to Figure 21-1, you will see two events leaving the Placed state. Both events have the<br />

same associated action, issueCustomerStmt(). Figure 21-3 shows the exit/action(s) notation<br />

added to the internal transitions compartment of the Placed state and the actions removed<br />

from the event arrows. Compare Figure 21-1 with 21-3 to appreciate the simplification.<br />

receive pmt<br />

Order is filled<br />

Filled<br />

Tentative<br />

Placed<br />

entry/issueConf()<br />

exit/issueCustomerStmt()<br />

authorize override<br />

cancel<br />

Cancelled<br />

Figure 21-3 Consolidating the exit actions<br />

Entry and exit action notations provide a nice simplification for the Statechart diagram.<br />

Just remember that they may only be used when the action takes place every time you<br />

enter (for entry actions) or every time you exit (for exit actions) the state. If there is even<br />

one exception, the notation may not be used for that action.<br />

Defining Send Events<br />

Figure 21-4 introduces the send event. A send event is used when the object in the<br />

Statechart diagram needs to communicate with another object. On a Statechart diagram,<br />

the source of the incoming events is not shown because the same event may come from any<br />

number of other objects and the response must be the same. But an outgoing event must<br />

define the receiving object whether it is only one object or a broadcast to many objects. It<br />

works in the same way you use your phone. You can receive calls without knowing who is<br />

calling. But you cannot place a call without the number you want to call.

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

Saved successfully!

Ooh no, something went wrong!