Creating a sequence diagram
A sequence diagram in UML shows the chronological sequence of messages between instances in an interaction. It consists of an interaction that is represented by lifelines and the messages that they exchange over time during the interaction.
In this section you're going to realize the use case "Search for a phone number" and show the
associated interaction using a sequence diagram. The use case starts with the actor Any User,
who makes use of the interface provided by PhoneBookView to request a search. PhoneBookView
notifies PhoneBookController about the user's request. PhoneBookController then updates
the data model that is stored in PhoneBookModel. Because there is a change of the model,
PhoneBookModel notifies PhoneBookView, which should then refresh the user interface to
reflect the latest state of the application.
- In the Model Explorer view, right-click Phone Book UML Model and select Add Diagram > Sequence Diagram.
- Enter
Sequence Diagramas the name of the generated diagram to replace the default name Diagram1. - Drag the actor Any User from the Model Explorer view to the diagram to create an instance
of the actor, as shown in Figure 10. Similarly, create instances of PhoneBookView, PhoneBookController and
PhoneBookModel by dragging them to the diagram.
Figure 10. Drag the model elements to the sequence diagram
- Select Asynchronous Message in the Palette. As shown in Figure 11, click the line under any User: Any User
and then the line under phoneBookView:PhoneBookView.
Figure 11. Create message line
- Select the operation PhoneBookView::getUserInput() from the drop down list.
Figure 12. Select operation for a message line
- Similarly, create the following Asynchronous Message lines shown in Table 3.
To create an Asynchronous Message to call itself, simply click the instance
bar directly without any dragging.
Table 3. Message lines for the sequence diagram
From instance To instance Operation phoneBookView phoneBookController PhoneBookController::userHasInput() phoneBookController phoneBookModel PhoneBookModel::searchPhoneNumber() phoneBookController phoneBookModel PhoneBookModel::setState() phoneBookModel phoneBookView PhoneBookView::stateHasChanged() phoneBookView phoneBookModel PhoneBookModel::getSearchResult() phoneBookView phoneBookView PhoneBookView::changeView() - The complete sequence diagram should look like Figure 13. Select File > Save All to save everything.
Figure 13. Complete sequence diagram





