Sequence diagrams

A sequence diagram is an interaction diagram that emphasizes the time ordering of messages [BRJ99]. A sequence diagrams represents objects participating in the interaction in a timely manner. The time when messages are sent to objects is important and altering this order may produce unexpected results.

Figure 6-5 shows an example of a sequence diagram. Farmer plays the role of an actor as the farmer sends a request to the system to obtain some weather data.

farmer: Farmer


1 : s electWeatherStation

2: selectTimelnterval

3: getWeatherData weatherManacier : WeatherManaqer

4: getWeatherData(weatherStation,timelnterval)

5: returned Data

6: displayData I

Figure 6-5. Example of a sequence diagram.

Farmer communicates with object GUI (Graphical User Interface). The sequence of messages sent between the objects described in Figure 6-5 is as follows.

First, the farmer needs to select a weather station from the list displayed by the GUI object. Second, the farmer needs to select a time interval for the weather data. Third, the farmer needs to press the button GetWeatherData. Object GUI sends the message getWeatherData(weatherStation Jimelnterval) to object Weather Manager. Note that this message has two parameters selected by the farmer: The weather station and the time interval for the data. WeatherManager will execute the message and return the data to object GUI that sends himself the message displayData. The farmer can then read the displayed data.

In this particular example, the order of the first two messages the farmer sends to GUI can be reverted; the farmer may select the time interval first and then select a weather station. It is understandable that message 4, getWeatherData(weatherStation, timelnterval), cannot be executed before message 3, getWeatherData.

In a sequence diagram, objects are shown as vertical lines as shown in Figure 6-6. The vertical line is referred to as object's lifeline. The lifeline shows when an object is created and how long its life would be. Lifelines are used to model class behavior. Figure 6-6 shows that Farmer is the name of the class and farmer is an object of class Farmer.



0 0

Post a comment