Question about the sequence diagram in T1

In the sequence diagram in Question C, after calling the method register(), a reference to the account a is returned to the user, which is correct according to the UML. But why, then, do we need to call login() just to get the same reference again? Isn’t it redundant in this case?

I understand why both methods exist in general; I am just asking whether, in this case, it would suffice to call only register(), even though the scenario states that the user both registers and then logs in.

Regards,
Mahmoud

Hi Mahmoud,

Since register(...)has the return type Unit according to the class diagram, it doesn’t return an output. In contrast, login(...)has a return type of Account, so it returns a reference to the account a.

Thus, we correct this in the sequence diagram by removing a from the dashed line (return) of register(...).

Best,
Aiman

3 Likes