简体   繁体   中英

Are messages in sequence diagrams the exact methods or are they more abstract?

I am trying to draw some sequence diagrams. The diagrams are not for design purposes I have to admit, they are thought as an explanation for the programmers who will keep working on the source code. As far as I understand, the messages between lifelines stand for the methods. However the diagrams would be too detailed if I were to draw every single method call for a specific scenario. At some points I want to give the exact names of the methods, but I also want to keep some of the actions more abstract. Is it OK to mix them up? For example: A: lifeline 1 B: lifeline 2 1st message from A to B: create (constructor, a real method) 2nd message from A to B: prepare (abstract, refers to a set of configurations etc) 3rd message from A to B: doSomeAction (a real method) I believe it should be fine, but I should at least differentiate between methods and more abstract messages. Any ideas? Thanks in advance!

I wouldn't mix them up or abuse the notation, I would use messages, and, optionally, signal receptions, for things that are not operations. Signal receptions can later call or be replaced with specific operations.

In general, no, messages do not need to correspond to methods. Sequence diagrams are often used in use case modelling to describe the interaction between and actor and the system, and those are typically not methods.

But it does depend on what you are trying to describe. I'd say that if your lifelines represent actual classes and interfaces, you should not mix real methods with abstract messages because that will tend to confuse, not clarify. In UML, you should always remember that there is a defined strict interpretation, and if you don't know it but your readers do you may end up speaking nonsense.

In practical terms, UML does not distinguish methods from other types of messages, but you can always represent this with a stereotype.

And as always, when in doubt, add notes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM