I am working on a system (B) that communicates with another system (C) and displays calculated values in a ongoing loop at a terminal (A). (A) asks (B) to report a variable x
. (B) does so without blocking, so that (B) can continue to deal with (C). Later, (A) asks (B) to also report the variable y
, which will served by (B) in the same manner.
For documentation, I need to create a UML sequence diagram (using plantuml
) describing the process. My trouble now is how to model it properly. The communication between (B) and (C) goes on even though the loop has not finished. But how do I model that correctly?
Here's option 1, just using a asynchronous reply in the loop:
@startuml
A ->> B: report x
loop
B -->> A: x
end loop
B -> C: foo
C --> B: bar
A ->> B: report y
loop
B -->> A: y
end loop
B -> C: qux
C --> B: baz
@enduml
Option 2 works with a condition that becomes true later in the process:
@startuml
A ->> B: report x
loop until reporting x ends
B -->> A: x
end loop
B -> C: foo
C --> B: bar
A ->> B: report y
loop until reporting y ends
B -->> A: y
end loop
B -> C: qux
C --> B: baz
B -->> A: end reporting x
B -->> A: end reporting y
@enduml
Option 2 is more explicit. But does any of the two options denote the process at hand correctly?
They are probably both correct. A SD shows a concrete view on a process. Since time is linear (forget about those quantum leaps here) and you don't really have parallel processes, you will have one object sending or receiving a message at a single time and nothing in parallel. It's up to you which sequence you represent. Probably you need more than one sequence to give a half ways clear picture.
To show really parallel processes you'd need two time lines (e.g. if you have two parallel processors and two forks of the same process running in parallel). If needed you can then add timing constraints and show that certain things are (almost) parallel.
I guess it's a good idea to add a state diagram that shows how transitions are supported and where who has to wait when and how long.