Reputation: 21
Do I need to have an if and else guard in a sequence diagram when using an alternative flow? For example, if I have a website and a person decides to purchase an item, the item is reserved, if he does not pay then the product is deleted and so is the payment. So would it even make sense to have [if payment cost accepted] when you already specify it in the interaction between the Customer and the Interface:Interface?
Upvotes: 2
Views: 718
Reputation: 6318
Each of the alt flows has either explicit or implicit guard (see 17.6.3.7 in first paragraph). If no guard statement is provided then this is treated as an implicit true guard.
If you model various flows using the sequence diagram, even if you show only one of the flows on a particular diagram, you should put the guard there (otherwise you'll have a flow that is always executed and usually that's not what you want to model using alt).
As Uffe mentioned, the guard contains only a logical statement that is evaluated to either true or false (without the 'if' keyword).
Upvotes: 1
Reputation: 6529
If you do not specify a guard condition, both alternatives are skipped. Section 17.6.3.7 (Alternatives) of UML 2.5 says, "If none of the operands has a guard that evaluates to true, none of the operands are executed and the remainder of the enclosing InteractionFragment is executed."
Upvotes: 2