1

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?

4
  • Is it just the multiple creation or are you going to show how these multiple objects interact? Commented Jul 20, 2016 at 7:59
  • I just want to know how to create multiple objects. Commented 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. Commented Jul 20, 2016 at 13:12
  • Would you mind accepting and up-voting the answer if it proved useful? Commented Mar 13, 2018 at 7:31

1 Answer 1

2

Use a loop combined fragment, where a new object is created inside of a loop.

enter image description here

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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?
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?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.