nus-cs2103-AY1920S1 / forum

Forum
1 stars 1 forks source link

If-else return statements in sequence diagrams #191

Open KendrickAng opened 4 years ago

KendrickAng commented 4 years ago

In the lecture going through the sequence diagram past year question, the sequence diagram was drawn to have one return arrow in each of the if and else parts of an "alt" block. However, for Q2 of the mock practice paper, only one return arrow was drawn outside the alt block. Both had return statements in each of the "if" and "else" parts. Which convention should we follow?

image

image

Also, the second picture has an activation bar not exceeding the alt block while the bar exceeds the alt block in the first picture. Which one do we follow?

damithc commented 4 years ago

Both are fine if the return is same. If the return value is different for the different alternatives, it needs to be the first one.

Also, the second picture has an activation bar not exceeding the alt block while the bar exceeds the alt block in the first picture. Which one do we follow?

It follows the meaning of the diagram. In the second case, the return is not part of the alternative branches in which case it should be outside of the alt box. As we put the return outside the box, the activation bar too has to extend to outside of the box.

qweiping31415 commented 4 years ago

May I ask how should we deal with the parameters of generate(boolean hasExisting) executed in the past year question? hasExisting is passed as a parameter but is not reflected in the outer arrow before the alt box?

damithc commented 4 years ago

May I ask how should we deal with the parameters of generate(boolean hasExisting) executed in the past year question? hasExisting is passed as a parameter but is not reflected in the outer arrow before the alt box?

For context, can give a screenshot?

danielwys commented 4 years ago

Am wondering the same thing. The generate(boolean hasExisting) call is located in the first image, quoted below:

image

Should it be generate() or generate(hasExisting)?

damithc commented 4 years ago

Should it be generate() or generate(hasExisting)?

Should be generate(hasExisting) to be absolutely correct

danielwys commented 4 years ago

Thank you Prof!