Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Self Message vs Return Message in Sequence Diagram

What the difference between a self message and a return message. Here 2 examples:

Self Message:

self message

Return Message:

return message

Which example is correct?

like image 531
Haru Avatar asked Sep 05 '25 03:09

Haru


1 Answers

When lifelines are objects

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;
  }
  …
}

When an actor is involved

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 :

  • Both examples suggest
    interactions of a subsystem with a user instead of formal message exchange between objects. In both cases, the user would activate some button or menu that would tell the web interface that it should show a list.
  • In the first example, the explicit call of a display operation within the web interface suggests that some displaying would take place. We implicitly understand that the user would get some visual feedback.
  • In the second example, the return message suggests *explicitly a feedback to the user, in form of a displayed result.
like image 63
Christophe Avatar answered Sep 07 '25 19:09

Christophe