1

I mean, my supervisor said that the messages in my sequence diagram need to be the same as the function name that I intend to use when coding. So I am wondering a sequence diagram like the following one is legal or not: enter image description here

I mean, for example, the message Validate user password, does it have to be validateUserPassword() like what my supervisor said? I've been googling for half an hour without a proper answer. So can you guys help me with this problem? Thanks in advance!

Christophe
  • 68,716
  • 7
  • 72
  • 138
  • 1
    No, sequence diagrams are not formal code and are meant to illustrate a behavior of the system, so as long as they convey that then you're good. Yes, if your supervisor tells you YOUR sequence diagrams need the actual method names then that's what your getting paid to do, regardless whether another convention may be more beneficial to the reader. – Matthew May 17 '21 at 10:46
  • Thanks for your quick and comprehensive answer @Matthew. Btw, he is my thesis supervisor, not my boss at work. Looks like I will need to discuss with him a little bit about this problem. – Nguyễn Nam May 17 '21 at 10:49

1 Answers1

0

In short

UML is a flexible modeling language meant to be usable at every moment of the development cycle, and is not primarily meant as a formal visual programming tool. In this regard, you have freedom on message labeling in sequence diagrams, even if it is a good habit to refer to operations when these are known.

Some more arguments

Authoritative arguments

The UML 2.5.1 specification is clear about a message "signature" referring to either operations or signals (page 574, on message semantics):

The signature of a Message refers to either an Operation or a Signal. The name of the Message must be the same as the name of the referenced Operation or Signal.

xHowever, it leaves freedom regarding the notation of messages in diagrams, since the label on the arrow does not need to be the message signature (page 577 on message notation):

The message-name appearing in a request-message-label is the name property of the Message. If the Message has a signature, this will be the name of the Operation or Signal referenced by the signature. Otherwise the name is unconstrained.

Practical arguments

Sequence diagrams are used for a large range of purposes, including for specifying scenarios that illustrate use cases, i.e. for describing requirements, before classes and their operations are completely defined.

Moreover, UML does not require a sequential waterfall process, where you would first specify in all details the classes and their features, and only afterwards specify sequence diagrams. UML is method-agnostic and it is not uncommon that one designs classes in parallel to the sequence diagrams, the sequence diagrams helping to identify the operations missing in the class. Such sequence diagrams being modelled, they use a free message label before it can get formalised.

In defence of your supervisor, you must also aknowledge that such informal message labels bear some ambiguity. So it's not a bad thing to encourage a proper use of the message signatures ;-)

Use of actors in use-cases

Using actors in sequence diagrams is a tricky thing: a sequence diagram normally describes interaction between classifiers within the system, whereas actors are outside the system.

The formal way of doing it would be to use a boundary class instead of the actor (i.e. a class in the system that communicates with the user outside). Comments on the boundary activation could then describe its interactions with the user in plain text.

But actors in sequence diagrams, even if discutable, are nevertheless a popular practice (see this question for more details), and if you use it, it is clear that a user will not use function calls to communicate with the system.

Christophe
  • 68,716
  • 7
  • 72
  • 138