If I had an object user in sequence diagram and I wanted to make that object interact with the interface,should I use it's own functions?

76 views Asked by At

My object user is a part of the sequence diagram for reporting accidents and it interacts with a user interface. User interface acts as a middle man between user and object from class report. To indicate the report,user must send his data to the user interface. So should I draw an arrow from user to interface that uses a function from user as I did in the photo or what should I do?

sequence diagram If deemed useful, here the corresponding classes: class diagram

I searched for the solution online but found no useful answer.

2

There are 2 answers

7
Christophe On

Your sequence diagram seems to show the User as an actor. This is ambiguous, because actors are outside the system, whereas sequence diagram should show objects inside the system:

  • while it is ambiguous, it is nevertheless a common practice as explained in this other answer with additional recommendations.
  • in your class diagram, there is a class User that seems to be different from the actor, and be inside the system. If your sequence diagram refers to an object of this class, prefer using a normal lifeline without the actor symbol, to avoid any confusion.
  • your User lifeline sends messages that have the name of the operations of the User class. This is super-ambiguous, because the messages send should correspond to operations of the receiver and not the sender. So either your User class belongs to the system interface and you just need to avoid the naming ambiguity regarding the actor, or you need to rethink your messages.

As explained in the comments: if the user lifeline corresponds to a real user (e.g. a person), the messages could use informal wording instead of formal operations, as the user interacts with the system through input/output devices and doesn't call directly the operations. If you nevertheless use operations, use operation signatures of the receiver.

Not related:

You seem to use the alt with a message continue() that does not correspond to any operation of the receiver, just for the purpose of specifying what happens if the verification fails. If it's the case, you may prefer to use the more elegant break instead: this allows you to specify exacltly the kind of unfortunate path you want to model, without an unnecessary continue() workaround.

0
Axel Scheithauer On

Interaction in the physical world is usually asynchroneous. Since your user lifeline stands for the physical user, I would only use asynchroneous signals between it and the system.

The name of these signals should not include a verb like "send", since signals can be sent and received.

Your system interface component should have the corresponding receptions. Formally this would be required, but many tools allow a more flexible approach. I guess it is ok to not model the receptions, as long as you understand that they are to be defined on the target side of the signal message.

With the sequence diagram you define that the user sends the signals. If you want to show that in a class diagram, you could define an interface with receptions of the signals and a «use» dependency from the actor to the interface.