Book a Demo

Author Topic: Multiple instances on a sequence diagram  (Read 12617 times)

Mitch

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Multiple instances on a sequence diagram
« on: January 24, 2008, 12:02:42 pm »
I'm creating a one instance of an object of type A and two instances of an object of type B. I would like to use a sequence digram to show how the A object interacts with the two B objects. Is this possible?

When I drag a second instance of a class to a sequence or Communication diagram, EA tells me that it does not support multiple instances.

I'm no UML expert, so please suggest other UML diagram types to use for this situation.

revdev

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
  • Love this stuff.
    • View Profile
Re: Multiple instances on a sequence diagram
« Reply #1 on: January 24, 2008, 02:04:42 pm »
Create the classes in your domain model, perhaps as part of a package of classes.  Drag a class from the package onto the sequence diagram.  Select Advanced | Convert to instance.  This will let you drag the class from the explorer to the diagram again.  Covert that to an instance as well.  You now have 2 instances of the same class on the sequence diagram.

re-Vision Development

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Multiple instances on a sequence diagram
« Reply #2 on: January 24, 2008, 03:43:35 pm »
Quote
...
When I drag a second instance of a class to a sequence or Communication diagram, EA tells me that it does not support multiple instances.
...

The language in the error message is unfortunate. In UML the word "instance" often means a 'real' occurrence of a thing, in the sense that an object is an "instance" of a class. However the error message is referring to the attempt to add a specific class - there is only one definition of that class in your model - to the diagram more than once. This is the English use of instance, in the sense that a given class (definition) cannot occur twice.

So, the answer revdev provided is quite correct. You need to have two objects, each of which is an "instance" (in the UML sense of the word) of the class definition (which is still unique).

Hopefully I've made this a bit clearer - more than I've confused the issue.

Look up Instance | Paste Object As in the EA help file.

David
No, you can't have it!

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Oh, why stop now just when...
« Reply #3 on: January 24, 2008, 10:48:44 pm »
IAF the EA error message is stating that you cannot have more than one instance of the same element in a diagram.  By this they are saying that the modelling object is an instance, not that the object (real or classifier) is an instance of that thing.  As I have said elsewhere ... I don't believe that this is in accordance with the UML which simply states that any element in a model with the same (qualified) name represents the same thing, IOW two elements in a model with the same name ARE the same SINGLE thing.  IMHB it never said you cant have more than one element of the same name in a model(diagram).

I haven't got EA at the moment (Win box is "under repair").  But consider this.  Create two packages, as namespace roots if you like, and add a class "Fred" TO EACH.  Now, somewhere else create a sequence diagram and drag each of the classes as classifiers onto the diagram.  Are they the same thing? I think not.

htdctm
bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Mitch

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Multiple instances on a sequence diagram
« Reply #4 on: January 25, 2008, 07:09:12 am »
Thanks for the background. For a UML program it is an unfortunate re-use of the word "instance".

I also found two other ways:

1) hold the ctrl key down while dragging the object. It will pop up a dialog to choose between an instance and a class.

2) In the Tools->Options->Seq Diagram dialog there is a checkbox to set "auto instance"

Mitch

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Multiple instances on a sequence diagram
« Reply #5 on: January 25, 2008, 08:49:42 am »
Good stuff Mitch,

I think you're in the picture now - from both the UML way of thinking and the EA way of doing...

David
No, you can't have it!