Section 3.10. Ending Activities and Flows


3.10. Ending Activities and Flows

The end nodes in this chapter haven't been very interesting so far; in fact, they haven't acted as much more than end markers. In the real world, you can encounter more complex endings to processes, including flows that can be interrupted and flows that end without terminating the overall activity.

3.10.1. Interrupting an Activity

Figure 3-21 above shows a typical activity diagram with a simple ending. Notice there's only one path leading into the activity final node; every action in this diagram gets a chance to finish.

Sometimes you need to model that a process can be terminated by an event. This could happen if you have a long running process that can be interrupted by the user. Or, in the CMS order handling activity, you may need to account for an order being canceled. You can show interruptions with interruption regions .

Draw an interruption region with a dashed, rounded rectangle surrounding the actions that can be interrupted along with the event that can cause the interruption. The interrupting event is followed by a line that looks like a lightning bolt. Figure 3-22 extends Figure 3-21 to account for the possibility that an order might be canceled.

Figure 3-22. Interruption region showing a process that can be interrupted


In Figure 3-22, if a cancellation is received while Process Order is active, Process Order will be interrupted and Cancel Order will become active. Cancellation regions are relevant only to the contained actions. If a cancellation is received while Ship Order is active, Ship Order won't be interrupted since it's not in the cancellation region.

Sometimes you'll see activity diagrams with multiple activity final nodes instead of multiple flows into a single activity final node. This is legal and can help detangle lines in a diagram that has many branches. But activity diagrams are usually easier to understand if they contain a single activity final node.


3.10.2. Ending a Flow

A new feature of UML 2.0 is the ability to show that a flow dies without ending the whole activity. A flow final node terminates its own pathnot the whole activity. It is shown as a circle with an X through it, as in Figure 3-23.

Figure 3-23. A flow final node terminates only its own pathnot the whole activity


Figure 3-23 shows a search engine for the CMS with a two-second window to generate the best possible search results. When the two-second timeout occurs, the search results are returned, and the entire activity ends, including the Improve Search Results action. However, if Improve Search Results finishes before the two-second timeout, it will not stop the overall activity since its flow ends with a flow final node.

Be careful when using a flow final node after a fork. As soon as the activity final node is reached, all other actions in the activity (including the ones before the final node) terminate. If you want all forked actions to run to completion, make sure to add a join.





Learning UML 2.0
Learning UML 2.0
ISBN: 0596009828
EAN: 2147483647
Year: 2007
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net