Book a Demo

Author Topic: Modelling concurrency with sequence diagrams?  (Read 18291 times)

Tobi

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Modelling concurrency with sequence diagrams?
« on: October 02, 2009, 12:28:58 am »
Hi folks,

I don't know whether following is a general UML issue or Enterprise Architect related. It would be nice if you could help me in former case anyway.

I’d like to model communication within a distributed system and to express the (real) concurrency of some activities in the network. I thought a simple UML sequence diagram drawn in Enterprise Architect would be fine for this. I drag a few lifelines into my sequence diagram, each of them representing a peer in a network. I add some self-messages to each lifeline them and try to adjust them at same vertical position (to express concurrency). Enterprise Architect adjusts the messages automatically in sequence and disarranges the self-messages on the other lifelines. Can this somehow be avoided? Or is an UML sequence diagram just not suited for the purpose of modelling concurrency?

Best,
Tobias

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Modelling concurrency with sequence diagrams?
« Reply #1 on: October 02, 2009, 12:55:20 am »
Hi Tobias,

You CAN use sequence diagrams to model concurrency, they were designed also for that from the very first versions of UML. Concurrently excecuted messages are indicated with a simple arrowhead, sequential messages have a filled triangle arrowhead.
You can find a sample for that here in the EA documentation:
http://www.sparxsystems.com/uml_tool_guide/uml_dictionary/changing_the_timing_details.html

If you dig a bit more you should find more about this topic in the docs.
You can control this in the Messages' property dialog using the options from the 'Control Flow Type' section.

HTH
Günther

Tobi

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Modelling concurrency with sequence diagrams?
« Reply #2 on: October 02, 2009, 08:41:55 pm »
Hi Günther, thanks for your reply.

I guess using asynchronous messages is not the complete solution, as I'm still not able to model what I intend to do. A simple example:

There are three hosts on the network (host1, host2, host3, each modeled as an own lifeline). Host 1 sends a multicast message to all hosts and triggers an action sequence on each host. Action sequence is [ActionA1; ActionA2] on host 2, and [ActionB1;ActionB2] on host3. An action is modeled as a self message. (I could post a picture of this, but have no public web space available at the moment. Uploading images to this forum is not possible, is it?)

ActionA1 is related to ActionA2, it happens always previous to ActionA2 and ActionA2 will start only after ActionA1 has finished (=>synchronal sequence if considering host2 only). But ActionA* have no time relation to ActionB* as they run on different hosts which are not synchronized. So ActionA1 may happen before OR after ActionB1, this is what I want to show. Enterprise Architect assigns a sequence number (1.1, 1.2, …) to each message in the diagram which implies a fixed sequence order in the whole system (which is not true). As a consequence, if I draw ActionB1 a bit up, ActionA1 gets automatically drawn down. Do you have any suggestions how to avoid or handle this?

Tobias

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Modelling concurrency with sequence diagrams?
« Reply #3 on: October 02, 2009, 08:48:35 pm »
Tobias,

You can turn off the suquence numbering, so that should help.
For the rest I think you should be able to model that all in EA according to the UML specifications.

Geert

Tobi

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Modelling concurrency with sequence diagrams?
« Reply #4 on: October 02, 2009, 08:59:48 pm »
Hi Geert,

I've already tried to disable "Show Sequence Numbering" in Tools->Options->Diagram->Sequence. Did you mean this option? It only hides the sequence numbers, but in fact messages are still ordered and placed one after the other.

As I'm not too familiar with the UML I could imagine that my intention is simply not allowed by UML, and EA does nothing wrong...

Best,
Tobias

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Modelling concurrency with sequence diagrams?
« Reply #5 on: October 02, 2009, 09:23:20 pm »
Tobias,

Acutally I'm pretty sure that what you want to express is perfectly possible in UML. You might not like the way it is represented though.
It might indeed not be possible to display different messages at the same height in the sequence diagram, but since the messages are asynchronous that doesn't really matter, they are not going to wait for each other to finish.
So what you need to do is model asychronous messages to Host1, 2 and tree.
Those messages will start an activation.
Then whithin those activiations you create the syncronous messages (ActionA1, ActionA2 etc..)
I know that the lifelines will suggest a specific order in which the actions are executed, but since they are started by asynchronous messages you should interprete that as such.
So formally your diagram will not say that ActionA1 will be executed before ActionB1, but I can uderstand that you might think that given the different heights in the sequence diagram.

Another way to solve that issue to to model what happens on the hosts on separate sequence diagrams.
I think it is a best practice to model each operation on its own sequence diagram since you never know wether this operation might be called by another method then the one where you originally documented it. So in my sequence diagrams there is only one lifeline that sends messages. The other lifelines only accept messages. If you want to know what happens in the methods for the other lifelines you have to drill down to the appropriate sequence diagram.

Geert

Paul Lotz

  • EA User
  • **
  • Posts: 248
  • Karma: +1/-0
    • View Profile
Re: Modelling concurrency with sequence diagrams?
« Reply #6 on: October 06, 2009, 03:08:38 am »
You might consider using a Combined Fragment with a "par" (parallel)--or maybe even a "seq" (weakly sequenced)--operator:
http://www.sparxsystems.com/uml_tool_guide/uml_dictionary/interactionoperators.html.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Modelling concurrency with sequence diagrams?
« Reply #7 on: October 06, 2009, 07:26:42 pm »
That looks pretty sound and understandable. Thanks for the input paul.
I also had my problems how to visualize asynchronous behavior in the SDs,
and never found a really visually satisfying solution.

Günther

Tobi

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Modelling concurrency with sequence diagrams?
« Reply #8 on: October 06, 2009, 08:09:25 pm »
Hi, I think this sounds feasible too, and I'd like to say thanks to all for your replies! Tobias