Suppose I am creating an order handling system. A user may request many different kinds of product for an order. So an order consists of many orderlines. Whenever a customer makes an order the oder object has to create many orderlines objects. How to draw that in sequence diagram?
-
Is it just the multiple creation or are you going to show how these multiple objects interact?qwerty_so– qwerty_so2016-07-20 07:59:37 +00:00Commented Jul 20, 2016 at 7:59
-
I just want to know how to create multiple objects.Ju Ju– Ju Ju2016-07-20 13:01:26 +00:00Commented Jul 20, 2016 at 13:01
-
Then @Ister has the right answer. The exit condition from the loop is places in square brackets (like a guard). I'm sure he will update the picture.qwerty_so– qwerty_so2016-07-20 13:12:55 +00:00Commented Jul 20, 2016 at 13:12
-
Would you mind accepting and up-voting the answer if it proved useful?Ister– Ister2018-03-13 07:31:03 +00:00Commented Mar 13, 2018 at 7:31
Add a comment
|
1 Answer
Use a loop combined fragment, where a new object is created inside of a loop.
For a detailed description (including the guards as there is a bit more to tell - my example is a basic one) check UML documentation, sections 17.6.3.17 (for a description of semantics), 17.6.4.9 (to see how can you further limit number of loop runs by defining minimum and maximum number of runs) and 17.6.5, especially Figure 17.13 for examples.
3 Comments
Ju Ju
How to add condition to exist from that loop? In this case when the user press order button. I have to add another fragment 'break'? How about not using fragment, but adding *[not press order] before the message <<create>> from order to orderline? Becaue * means iteration and [] is used for iteration?
Ju Ju
I mean not using fragment totally. There will be only one message from orderline as *[condition]<<create>> and will orderline as multiobject. How about that?
Ister
You put a guard in square brackets, e.g. [order not complete]. The loop continues as long as the condition returns true. I've modified picture to show how it should look like. Guard is one for whole loop block.
