Home
Username:
Password:
UML Tutorials

Types of Diagrams: An Overview / Sequence & Communication Diagrams

Subtitles of the Movie

Now we're going to talk about two different kinds of interaction diagram, sequence diagrams and communication diagrams. Interaction diagrams go beyond static structural views of the system to offer dynamic view of how the systems objects communicate. Both sequence and communication diagrams show the messages that objects pass to each other even though they both show the same thing these two types of diagram have different emphasis. Sequence diagrams such as the one you see here emphasize the dimension of time, that is they emphasize the sequence or the ordering of interactions. On the other hand communication diagrams such as this one emphasize the participants in the interactions and the links between those participants. So to understand this difference we'll look at examples of each type of diagram in a little bit more detail. A sequence diagram such as this one shows the sequence, the ordering of interactions between the participants in those interactions. You get a clear picture of the order in which interactions take place and this is because a sequence diagram adds the dimension of time along the diagrams vertical axis. In a sequence diagram at the top of the diagram is earlier in time and then as you move down the diagram it represents later and later and later in time. The elements in a sequence diagram include participants and messages. Participants which might be objects or they might be actors, it's a fairly loose term, each participant has a lifeline, and you can see the dashed line that this sends from the classifier down toward the bottom of the diagram. That's the lifeline and that's where the representation of time comes in. Messages are shown horizontally and they extend from the lifeline of one participant to the lifeline of another participant or in the case of the self message the message extends from the lifeline of one participant back to that same lifeline. So as you can see a message that's higher up on the screen comes before a message that's lower down. So message one here comes before message two which comes before message three which comes before message four and so on. Another element that is optional in sequence diagram is this bar here and this is called activation. What the activation bar shows is a how long a particular participant is active in a given interaction. So a longer activation means the participant is active for a longer amount of time. So for participant one for example is active longer in this interaction then participant three because its activation bar is longer. These bars are optional and some people like them for the information they convey about length of activation, other people find that they clutter up the diagram and so they leave them off and that is a possibility. Sequence diagrams can be very helpful for showing how several objects interact within one particular use case. Actors, by the way can be participants in sequence diagrams, they can have lifelines and participate in the interactions just as objects can. So let's compare that with the communication diagram. A communication diagram shows much the same information as sequence diagram but as I said earlier its emphasis is different. You can think of a communication diagram as being like taking an object diagram and setting it in motion. An object diagram shows a snapshot of the configuration of objects at a particular moment in time, the communication diagram takes that object diagram snapshot and puts it into motion. As in a sequence diagram we have participants and we have messages. But rather then emphasizing time, communication diagram emphasizes the links between the participants. You see this line here between object one and object two, and another one between object two and object three. Those are links. And links indicate that the objects can communicate, messages can only pass along the links. So object one and object three cannot communicate directly, they cannot pass messages directly to one another because there is no link between them. The messages pass along the links as I've said and they can go in either direction. In this kind of diagram you can position your objects, your participants wherever you like and that allows these diagrams to be much more compacted then the sequence diagrams. Sequence diagrams as you can imagine from this example can get very wide horizontally. Communication diagrams can give the same information more compactly and although numbering the messages in a sequence is optional, here in a communication diagram its mandatory. You can imagine that as this communication diagram gets larger and there are more and more links between more and more objects it can become very confusing which message happens when unless you number them. Many people have a preference for either sequence or communication diagrams, you'll probably see more sequence diagrams then you see communication diagrams. Sequence diagrams are definitely the more popular of the two but each type has its place, use sequence diagrams to show time and to emphasize the sequence or the ordering of the interactions. Use communication diagrams to emphasize the links among the participants and as I suggested earlier a communication diagram can be a very helpful supplement to your object diagrams.

Tutorial Information

Course: UML
Author: Nancy Conner
SKU: 33815
ISBN: 1-934743-23-2
Release Date: 2007-10-26
Duration: 7 hrs / 95 lessons
Captions: For Online University members only
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available