| Member of the Month | Click Here for more information about how you can become Member of the Month |
Sequence Diagrams
Sequence diagrams model the interactions of objects over time. The diagram is used to show the objects of a system and the messages between those objects. It is called a sequence diagram because it represents the sequence of messages between objects in a time related fashion. In the Analysis phase, sequence diagrams are used to model the various scenarios as described in the flow of events. The sequence diagrams help to describe the chain of events that must take place in order to accomplish a given scenario. A sequence diagram is designed to show one particular scenario. Use cases will have primary and secondary scenarios. In addition, there may be exception or alternate scenarios. If a given scenario has decision points, then it is best to model the scenario with multiple sequence diagrams. Sequence diagrams are one of the primary modeling tools used during analysis. You want to model as many scenarios as possible in order to fully describe a system. Once modeling starts having a diminishing return in terms of discovery, then you have done enough.
As stated, the sequence diagram models object interactions. Using the example, no objects have yet been discovered. We have looked at actors, use cases, and interactions. What are the objects of a system? Some methodologists state that defining classes should be done early during the analysis. The classes are those entities in a system with state and identity. They will be described later in this paper. My personal belief is that defining classes is an activity that flows out of composing sequence diagrams. I use the diagrams to model sequences of activity for a scenario and "discover" the classes along the way. Attempting to discover those classes prior to actual analysis is a little more difficult. You may discover otherwise.
A sequence diagram in UML is drawn using objects and time lines. The objects are drawn as rectangles containing the name of the object or class underlined. The object can be named in one of three ways: the object name, the class name, or both the class and object name. They are represented as follows:
![]() |
The object in a diagram is shown with the rectangle and a timeline below the object. This timeline is used to model the messages between objects. The timeline is represented as a dashed line. Messages between objects are modeled as lines with arrows showing the direction of flow. An object with its timeline and object interaction would look as follows:
![]() |
Notice the message labeled Process. This identifies an object interaction indicating a message to itself. This can be used to model an internal process or some other object activity. The messages read from top to bottom in the diagram. This represents the sequence of events in time.
The objective is to represent a scenario and to keep it simple and yet descriptive. If you find that a particular diagram gets too complicated, then it is advisable to break it up into multiple diagrams. With the use of sequence diagrams a lot of information can be discovered about a system. A useful technique for analysis of a system is to analyze the use cases and scenarios and draw a diagram for each. All requirements of the system can be modeled in this way. Using gap analysis between the requirements specification, the use cases, and the sequence diagrams can ensure that all requirements are met.



