2

In a sequence diagram i am trying to model a loop that creates a bunch of objects. i have found little information online regarding the creation of multiple objects in an SD diagram so i turn to you.

The classes are Deck and Card

Cards are created by fillDeck(), which is called by the constructor of Deck (FYI the objects are stored in an arraylist in Deck).

There are many types of cards with varying properties. Suppose i want 8 cards of type A to be made, 12 of type B and 3 of type C

How would i go about modelling such a thing? this is the idea i have in mind so far, but it is obviously incomplete.

Hope someone can help! thanks!

    +------+
    | Deck |
    +------+
       |
    +--+-------+--------------+
    | loop 8x /               |
    +--+-----+   +----------+ |
    |  |-------->| Card(A)  | |
    |  |         +-----+----+ |
    +--+----------------------+
       |               |
    +--+--------+------|-----------------------+
    | loop 12x /       |                       |
    +--+------+        |          +---------+  |
    |  |------------------------->| Card(B) |  |
    |  |               |          +----+----+  |
    |--+---------------------------------------+
    |  |               |               |
    +--+-------+----------------------------------------------+
    | loop 3x /        |               |                      |
    +--+-----+         |               |        +---------+   |
    |  |--------------------------------------->| Card(C) |   |
    |  |               |               |        +----+----+   |
    |--+------------------------------------------------------+
       |               |               |             |

3
  • Why do you find it "obviously incomplete"? Commented Mar 5, 2014 at 14:58
  • i have only 3 lifelines, whereas i have 23 objects. Note, that having 23 lifelines would be cluttered as hell, but the way it is now, i'm not convinced it correctly represents that many more objects are created Commented Mar 5, 2014 at 17:14
  • Oh, foolish me, I have forgotten: +1 and welcome to StackOverflow! Commented Mar 7, 2014 at 11:58

1 Answer 1

1

"A sequence diagram describes an Interaction by focusing on the sequence of Messages that are exchanged, along with their corresponding OccurrenceSpecifications on the Lifelines." (UML standard) A lifeline are defined by one object. But that doesn't mean you must keep all objects in lifelines. You should show only these lifelines, that are exchanging messages you are thinking about.

And you needn't show all messages sequences logic on one diagram. In one SD normally you are showing one Interaction. Or maybe a few of them, if they are simple.

So, if your SD is showing one logical concept, it is correct. If there will be another interaction between some objects, you will draw another SD for this interaction, and there will be only objects participating in this second interaction.

UML standard 2.5. Figure 17.25 - Overview of Metamodel elements of a Sequence Diagram

enter image description here

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

2 Comments

thanks! It makes sense to shift the focus from the objects themselves to the messages exchanged by them. after all, to show relations between objects/classes we already have the DCD and others
@QualiosRex Of course. BTW, if you want to analyze objects individually, there are Object diag for it. And for thorough analyze of a class or two there is a Composite Structure diag.

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.