How do I continue correctly after if-then (w/o) else in an activity diagram?

0 votes
asked Dec 16, 2012 in Closed question / help by anonymous
Here a simple example in C:

if ( cond1) {

  act1();

}

if ( cond2 ) {

       act2();

}

Currently I need to insert a dummy activity between the if-clauses:

@startuml
scale 0.6
(*)-->if "cond1" then
  -->[true] "act1"
  -->  "dummy" as a1
else
  -->[false] a1
endif
a1 --> if "cond2" then
       -->[true] "act2"
       --> "dummy2" as a2
     else
       -->[false] a2
     endif
a2-->"act2"
-->(*)
@enduml

1 Answer

0 votes
answered Mar 22, 2013 by karthicks (140 points)

Try this:

@startuml
scale 0.6
(*)-->if "cond1" then
    -->[true] "Do Action1"
    --> a1
else
    -->[false] a1
endif
a1 --> if "cond2" then
    -->[true] "Do Action2"
    --> a2
else
    -->[false] a2
endif
a2-->(*)
@enduml

 

My understanding of what you want is that if the cond1 is satisfied, then you want to do something and if not you don't want to do the action. However, in either case, you want to come to cond2. Sounds right?

- Karthick S.

...