Activity Embedded Inside Activity - Conditionals

0 votes
asked Jan 17, 2021 in Wanted features by ndv (140 points)

We have some activity diagrams for modeling functions which return a value, each in its own plantuml file. 

I'd like to use/include those in bigger activity diagrams, rather than have a "call function()" activity. !include has been really useful to avoid repeating ourselves (just like functions should do)

The important part is showing the activity flow for each of the returned value.

I've tried embedding those into the conditional itself, with no success. 

I've tried embedding those into notes before/after the conditional, and it looks weird. I cannot make the note link against the conditional.

Here's a diagram which showcases several of my attempts:

http://www.plantuml.com/plantuml/uml/ZPBlQjim4C2_trDSoc3sAwIbQ-A5CUY7qctiisgVOn7bPAHpHmX-zvt5xCKqXWY3zUTEzxiVUefYWdH71_5WkJN17D6KOj-jdF0Cg6DhoiC--8whmZiV7XxsWOWV7_7PxXlvDYoknmMgngZ21-EW1u1L6tn9LHS8FraM2cnSbiDdV75a8k7tezbR9fJ6HjJFCAuibwwh2ElWbOwzD1Imjex0rfYrpl3GmH1TUk--v9fCZDcmo67YNPyetWCvBPA9vPF6nuvo-0UwPg-dNDaQLlgRC06I8e3rRtEWNo_t0Af9h5ZFU5VR40MD21rRkLDZwwAXye25rcQAMb1n2SCW0Svdq3n7cFRCctyd9UOgtQL-BeNq_G2J8bENhnGx9rDlsak-VFKREV_dfgjHntz3nUvvjttT_DoDdjZda696IJysNqTBFLGafcncFY8DLI-5N1pgL6VYMVVdH4ijti2tX3VIzJC-QMoOuItntVAqiaq-LlduhBBjT3ZwIWbNkudYsvGnQoJjzl2a-Ghn5m00

In the first attempt, I'd be happy if the embedded note was inside the conditional. Having to manually add a "result" step is too artificial.

In the second attempt, I'd like to skip the "result?" step, and create a direct link from "Yes" to "CELEBRATE", and from "no" to "SAD". 

In the third attempt, which is my least favorite as it uses connectors, I'd like to have actual arrows between connectors, and maybe for horizonal alignment between (A) and (B). I think implementing this option is the smallest syntax change: "skinparam ConnectedConnectors true"

I've noted that because of the structure of the syntax, its impossible to conditionally exit from a partition: all branches of a conditional that starts within a partition must end before the partition ends. Perhaps a break/return statement could be of use. I'm aware of swimlanes, but it did not fit well.

Thanks for your awesome support.

commented Jan 18, 2021 by Martin (8,360 points)

Personally I liked the "note below conditional" on your first option.  But I get that you would prefer to embed the subdiagram inside the 'result' condition lozenge itself.  Being able to put subdiagrams inside activity steps generally would also be powerful.

For option 3, have you considered using fork?

Other than that, my only other suggestion is sending the two result flows into the procedure as arguments.  But I realise it doesn't read as neatly.

@startuml
skinparam activity {
    BackgroundColor<<green>> LightGreen
    BackgroundColor<<red>> LightCoral
}


!unquoted procedure $internal($result1, $result2)
' Please Imagine this is an !include from another file
if (plantuml is cool?) then (cool)
!if %function_exists($result1)
%invoke_procedure($result1)
!else
:undefined;
!endif
else (tiny issue)
!if %function_exists($result2)
%invoke_procedure($result2)
!else
:undefined;
!endif
endif
!endprocedure


start

:WakeUP;

partition "fourth attempt" {

!procedure $flow1()
<<green>>:CELEBRATE;
!endprocedure

!procedure $flow2()
<<red>>:SAD;
!endprocedure

$internal("$flow1","$flow2")

}
@enduml

commented Jan 18, 2021 by ndv (140 points)

I did consider using fork, but I was afraid of accidentally implying concurrency for the sake of alignment. (The diagrams are often read by developers as design in plaintext form rather than as drawn documentation. )

If only I had a keyword that would draw similar to "fork" but without using "fork" keyword...

I did try your suggestion to use callback functions - It was a clever way to use the syntax, and it did work! but it felt hard to read and write (feels like async code). This alternative also does not highlight which are the "internal" parts (that is, I'd like for the CELEBRATE/SAD steps to be outside of the "fourth attempt" partition).

commented Jan 18, 2021 by Martin (8,360 points)
edited Jan 18, 2021 by Martin

Regarding "similar to fork but without implying concurrency", you can use split instead.

And Th has recently explained a clever method to make the entry arrows hidden (if wanted).

(click image for online server link)

Using split to remove the 'result' box in your second attempt, although it still has the 'pinch point' that you don't like.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...