Reputation: 91
What the difference between a self message and a return message. Here 2 examples:
Self Message:
Return Message:
Which example is correct?
Upvotes: 4
Views: 3991
Reputation: 3625
The self message is a message to self, and the reply message (you called it "return message") is a message to the sender of the preceeding synchroneous message. It is tied to this synchroneous message and as such cannot have an own name ("display"). It is always assumed to be there, even if you didn't model it in the second case. It can define a return value, but it would be shown after a colon. So the correct label on it would be
showing list:"some text"
It is OK to leave out the message name, but the colon should always be there when a return value is needed.
See the UML specification:
section 17.4.4.1 Message
A reply-message-label is used for reply Messages. It has the following form: <reply-message-label> ::= [<assignment-target> ‘=’] <message-name> [‘(’ [<output-argument-list>] ‘)’] [‘:’ <value-specification>]
As @Christophe has pointed out in his answer, the semantics of messages involving humans is not clearly defined. This is especially true for synchroneous messages. I would argue, that they don't make sense at all in real life situations. After sending a synchroneous message, the sender is supposed to wait for the reply message. I think it is not possible to force a human to do that. Therefore, I recommend to use asynchroneous messages here. For example, the display message to self could lead to an asynchroneous message being sent to the customer.
Upvotes: 1
Reputation: 73406
A self-message is a message like any other, except that it has a special addressee. Typically you would implement the first example by having one operation of a class call another operation of the same object. Pseudocode:
class WebInterface {
…
public void showList() {
…
display();
…
}
public void display() {
…
}
…
}
A return message provides a result back to the caller. Typically for a synchronous message implemented with a call of an operation, it would correspond to the return of the value. Pseudocode:
class WebInterface {
…
public Display showList() {
Display display;
…
return display;
}
…
}
In your examples, you use an actor in the sequence diagram. In principle, an actor is external to the system whereas a sequence diagram shows message exchanges within the system. Although this practice is popular, it is ambiguous, because no semantics are defined for exchanging messages with a human being.
In this particular context it’s a more informal meaning :
display
operation within the web interface suggests that some displaying would take place. We implicitly understand that the user would get some visual feedback.Upvotes: 3