Download UML Guide

Transcript
Model Elements
Adding Classifier Roles
Because classifier roles in sequence diagrams often represent instances of classes that are
also present in your model, you may want to create the class diagrams first. You can
show the relevant classes and the relationships among them in those diagrams and then
use the existing model elements to create classifier roles. The easiest way to do this is
simply by dragging and dropping a model element from the model browser into a diagram:
❏ If the dropped model element is a use case, class, interface, or actor, a new classifier role will be created and displayed in the diagram. The new classifier role will
have the dropped model element as its base type.
❏ If the dropped model element is itself a classifier role, that role will be displayed
in the diagram.
If you think of classifier roles as analogous to objects, then a role's base classifier is the
class to which that object belongs. When you drag and drop a class into a sequence diagram, you are in effect inserting an "instance" of that class.
The Actor button on the drawing toolbar (see Figure 6.2) not only creates a new classifier role but also a new actor to serve as a base classifier for that role. (When you use it,
you will see both new model elements appear in the browser under the Model folder.)
The new classifier role visually indicates that its base is an actor by displaying a very
small stick figure to the right of its title box. The Actor tool is just a convenience feature;
you could get the same effect by right-clicking the Model folder in the browser, selecting
"Add New Actor," and then dragging and dropping that new actor into the sequence
diagram.
6.2.2
Messages
A message represents a directed communication between classifier roles. Like relationship model elements such as associations and generalizations, a message is drawn as a
line.
Unlike relationship model elements, messages do not model physical structure; they
model behavior. However, it is important to note that behavior implies structure: if an
object of one type can send a message to an object of another type, the first object typically contains some kind of reference to the second.
In most cases, the time it takes to send a message may be considered instantaneous. For
this reason, messages are usually drawn as horizontal lines: the sending and receiving
ends appear at the same vertical level, and hence at the same moment in time. However,
this need not be the case. A message may represent a method call using a Remote Proce-
6-5
6. Sequences
6.2.1.2