Section 7.3. Events, Signals, and Messages


7.3. Events, Signals, and Messages

The smallest part of an interaction is an event. An event is any point in an interaction where something occurs, as shown on Figure 7-4.

Figure 7-4. Probably the most common examples of events are when a message or signal is sent or received


Events are the building blocks for signals and messages. Signals and messages are really different names for the same concept: a signal is the terminology often used by system designers, while software designers often prefer messages.

In terms of sequence diagrams, signals and messages act and look the same, so we'll stick to using the term "messages" in this book.

An interaction in a sequence diagram occurs when one participant decides to send a message to another participant, as shown in Figure 7-5.

Figure 7-5. Interactions on a sequence diagram are shown as messages between participants


Messages on a sequence diagram are specified using an arrow from the participant that wants to pass the message, the Message Caller, to the participant that is to receive the message, the Message Receiver. Messages can flow in whatever direction makes sense for the required interactionfrom left to right, right to left, or even back to the Message Caller itself. Think of a message as an event that is passed from a Message Caller to get the Message Receiver to do something.

7.3.1. Message Signatures

A message arrow comes with a description, or signature. The format for a message signature is:

 
attribute = signal_or_message_name (arguments) : return_type

You can specify any number of different arguments on a message, each separated using a comma. The format of an argument is:

 
<name>:<class>

The elements of the format that you use for a particular message will depend on the information known about a particular message at any given time, as explained in Table 7-2.

Table 7-2. How to understand the components of a message's signature

Example message signature

Description

doSomething( )

The message's name is doSomething, but no further information is known about it.

doSomething(number1 : Number, number2 : Number)

The message's name is doSomething, and it takes two arguments, number1 and number2, which are both of class Number.

doSomething( ) : ReturnClass

The message's name is doSomething; it takes no arguments and returns an object of class ReturnClass.

myVar = doSomething( ) : ReturnClass

The message's name is doSomething; it takes no arguments, and it returns an object of class ReturnClass that is assigned to the myVar attribute of the message caller.





Learning UML 2.0
Learning UML 2.0
ISBN: 0596009828
EAN: 2147483647
Year: 2007
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net