nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

Activity diagrams: Parallel paths #485

Closed Silvernitro closed 3 years ago

Silvernitro commented 3 years ago

Hi prof,

According to the textbook's section on activity diagrams, the execution of a program can only continue after all parallel paths have completed: Screenshot 2020-11-29 at 1 24 53 PM

However, there are cases where a program might execute multiple parallel operations but only waits for the first path to complete before returning, e.g. Javascript's Promise.any(). In such a case, can we simply bypass the join?

This is actually related to Week 9 Quiz 1 Q20. I was under the impression that the activity diagram was literally trying to say: "execute P1, P2, and P3 in parallel. If P3 is complete, simply exit the program without waiting for P1 and P2.", which is a legitimate flow for a program. image

GeNiaaz commented 3 years ago

I believe it is standard notation to follow the end on the same join node before pointing towards the "end" node regardless of program flow since they are parallel paths executed simultaneously.

damithc commented 3 years ago

However, there are cases where a program might execute multiple parallel operations but only waits for the first path to complete before returning, e.g. Javascript's Promise.any(). In such a case, can we simply bypass the join?

This kind of complex behaviors do exist but they are not suitable to be modelled using the activity diagram's definition of parallel paths (i.e., within the scope of the notations we have covered in the module).

Silvernitro commented 3 years ago

Got it, thanks prof! (and thanks @GeNiaaz for the quick reply too :D)