Terms and Concepts
An interaction is a behavior that comprises a set of messages exchanged among objects in a set of roles within a context to accomplish a purpose. A message is a specification of a communication between objects that conveys information with the expectation that activity will ensue.
Internal structure diagrams show the structural connection among roles, as discussed in Chapter 15; objects are discussed in Chapter 14; systems and subsystems are discussed in Chapter 32; collaborations are discussed in Chapter 28 . |
Context
You may find an interaction wherever objects are linked to one another. You'll find interactions in the collaboration of objects that exist in the context of your system or subsystem. You will also find interactions in the context of an operation. Finally, you'll find interactions in the context of a class.Most often, you'll find interactions in the collaboration of objects that exist in the context of your system or subsystem as a whole. For example, in a system for Web commerce, you'll find objects on the client (such as instances of the classes BookOrder and OrderForm) interacting with one another. You'll also find objects on the client (again, such as instances of BookOrder) interacting with objects on the server (such as instances of BackOrderManager). These interactions therefore not only involve localized collaborations of objects (such as the interactions surrounding OrderForm), but they may also cut across many conceptual levels of your system (such as the interactions surrounding BackOrderManager).You'll also find interactions among objects in the implementation of an operation. The parameters of an operation, any variables local to the operation, and any objects global to the operation (but still visible to the operation) may interact with one another to carry out the algorithm of that operation's implementation. For example, the operation moveToPosition(p : Position) defined for a class in a mobile robot will involve the interaction of a parameter (p), an object global to the operation (such as the object currentPosition), and possibly several local objects (such as local variables used by the operation to calculate intermediate points in a path to the new position).
Operations are discussed in Chapters 4 and 9; modeling an operation is discussed in Chapters 20 and 28 . |
Classes are discussed in Chapters 4 and 9 . |
Components are discussed in Chapter 15; nodes are discussed in Chapter 27; use cases are discussed in Chapter 17; modeling the realization of a use case is discussed in Chapter 28; classifiers are discussed in Chapter 9 . |
Objects and Roles
The objects that participate in an interaction are either concrete things or prototypical things. As a concrete thing, an object represents something in the real world. For example, p, an instance of the class Person, might denote a particular human. Alternately, as a prototypical thing, p might represent any instance of Person.NoteIn a collaboration, the interactors are usually prototypical things that play particular roles, not specific objects in the real world, although it is sometimes useful to describe collaborations among particular objects.In the context of an interaction, you may find instances of classes, components, nodes, and use cases. Although abstract classes and interfaces, by definition, may not have any direct instances, you may represent instances of these things in an interaction. Such instances do not represent direct instances of the abstract class or of the interface, but may represent, respectively, indirect (or prototypical) instances of any concrete children of the abstract class of some concrete class that realizes that interface.
Abstract classes are discussed in Chapter 4; interfaces are discussed in Chapter 11 . |
Instances are discussed in Chapter 13; object diagrams are discussed in Chapter 14 . |
Links and Connectors
A link is a semantic connection among objects. In general, a link is an instance of an association. As Figure 16-2 shows, wherever a class has an association to another class, there may be a link between the instances of the two classes; wherever there is a link between two objects, one object can send a message to the other object.
Figure 16-2. Associations, Links, and Connectors

Roles, connectors, and internal structure are discussed in Chapter 15; collaborations are discussed in Chapter 28 . |
Messages
Suppose you have a set of objects and a set of links that connect those objects. If that's all you have, then you have a completely static model that can be represented by an object diagram. Object diagrams model the state of a society of objects at a given moment in time and are useful when you want to visualize, specify, construct, or document a static object structure.
Object diagrams are discussed in Chapter 14 . |
Operations are discussed in Chapters 4 and 9; signals are discussed in Chapter 21 . |
Figure 16-3. Messages

Create and destroy are visualized as stereotypes, which are discussed in Chapter 6; the distinction between synchronous and asynchronous messages is most relevant in the context of concurrency, as discussed in Chapter 23 . |
Classes are discussed in Chapters 4 and 9 . |
Interfaces are discussed in Chapter 11 . |
Sequencing
When an object passes a message to another object (in effect, delegating some action to the receiver), the receiving object might in turn send a message to another object, which might send a message to yet a different object, and so on. This stream of messages forms a sequence. Any sequence must have a beginning; the start of every sequence is rooted in some process or thread. Furthermore, any sequence will continue as long as the process or thread that owns it lives. A nonstop system, such as you might find in real time device control, will continue to execute as long as the node it runs on is up.
Processes and threads are discussed in Chapter 23 . |
Systems are discussed in Chapter 32 . |
Figure 16-4. Procedural Sequence

Figure 16-5. Flat Sequence

Processes and threads are discussed in Chapter 23; you can also specify asynchronous flow of control, rendered using a half-stick arrowhead, as discussed in Chapter 23 . |
specifies that the operation ejectHatch is dispatched (with the actual argument 3) as the fifth message in the sequence rooted by the process or thread named D.Not only can you show the actual arguments sent along with an operation or a signal in the context of an interaction, you can show the return values of a function as well. As the following expression shows, the value p is returned from the operation find, dispatched with the actual parameter "Rachelle". This is a nested sequence, dispatched as the second message nested in the third message nested in the first message of the sequence. In the same diagram, p can then be used as an actual parameter in subsequent messages.
D5 : ejectHatch(3)
Iteration, branching, and guarded messages are discussed in Chapter 19; timing marks are discussed in Chapter 24; stereotypes and constraints are discussed in Chapter 6 . |
NoteIn the UML, you can also model more-complex forms of sequencing, such as iteration, branching, and guarded messages. In addition, to model timing constraints such as you might find in real time systems, you can associate timing marks with a sequence. Other, more exotic forms of messaging, such as balking and time out, can be modeled by defining an appropriate message stereotype.
1.3.2 : p := find("Rachelle")
Creation, Modification, and Destruction
Most of the time the objects you show participating in an interaction exist for the entire duration of the interaction. However, in some interactions objects may be created (specified by a create message) and destroyed (specified by a destroy message). The same is true of links: The relationships among objects may come and go. To specify if an object or link enters and/or leaves during an interaction, you can attach a note to its role within a communication diagram.During an interaction, an object typically changes the values of its attributes, its state, or its roles. You can represent the modification of an object in a sequence diagram by showing the state or the values on the lifeline.
Lifelines are discussed in Chapter 19 . |
Representation
When you model an interaction, you typically include both roles (each one representing objects that appear in an instance of the interaction) and messages (each one representing the communication between objects, with some resulting action).You can visualize those roles and messages involved in an interaction in two ways: by emphasizing the time ordering of its messages, and by emphasizing the structural organization of the roles that send and receive messages. In the UML, the first kind of representation is called a sequence diagram; the second kind of representation is called a communication diagram. Both sequence diagrams and communication diagrams are kinds of interaction diagrams. (UML also has a more specialized kind of interaction diagram called a timing diagram , which shows the exact times at which messages are exchanged by roles. This diagram is not covered in this book. See the UML Reference Manual for more information.)Interaction diagrams are discussed in Chapter 19 .