nus-cs2103-AY2324S2 / forum

16 stars 0 forks source link

Practice exam part 2 sequence diagram #1050

Closed sindhurajain closed 6 months ago

sindhurajain commented 6 months ago

For this question

image

I'm trying to understand why the activation bar for init is within the activation bar for the client constructor (and why init and the constructor don't have separate activation bars) whereas the activation bars for add and set are separate

image

Can I check if my reasoning is correct: The client constructor is still in use and hasn't been returned throughout the time init is called so the activation bar for init is within the activation bar for the client constructor But for the add and set methods, their execution is separate. Since the activation bar should be unbroken until the method is returned, once one method returns, the activation bar can be broken and a new one is created for the other method

yuechen2001 commented 6 months ago

Yep i think your reasoning is correct. Basically the constructor for Client only returns after the execution of s.set(port), hence the activation bar remains unbroken until the 2 parallel-executed methods return. The reason why init is within the constructor activation bar is because it is called upon within the constructor (and before it returns), hence it's considered a method of Client object calling another method of the same object, therefore the two activation boxes are stacked ontop of each other.

sindhurajain commented 6 months ago

Thanks!