Book a Demo

Author Topic: Virtual Method calls in a Sequence Diagram  (Read 10263 times)

JohnWSaundersIII

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Virtual Method calls in a Sequence Diagram
« on: August 10, 2005, 12:21:11 pm »
I have a piece of code which uses a factory to create an instance of the appropriate derived class given the input parameters to the factory. The code then needs to call a virtual method of whichever derived class instance.

How do I show this on an Interaction diagram? I couldn't figure out how to do it with an "alt" fragment, for instance.

Thanks,
John Saunders
John Saunders

TrtnJohn

  • EA User
  • **
  • Posts: 176
  • Karma: +0/-0
    • View Profile
Re: Virtual Method calls in a Sequence Diagram
« Reply #1 on: August 31, 2005, 05:12:53 pm »
I'd like to know the best way to do this too.  I noticed there is a insert as New Child (Generalization) in the paste menu when you drag a class into the diagram.  But, it is grayed out in my version.  I'd like to have a lifeline for each child class so I can show which virtual method in which class is used.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Virtual Method calls in a Sequence Diagram
« Reply #2 on: September 01, 2005, 01:07:50 am »
I think, from memory when I went through this about a year ago I had to actually create a "sample" code and work backwards to the seq diagram.  IIRC it was tricky.  IIalsoRC the trick was to remember to work with real instances in the diagrams.

I dont have the result sorry - dont work there no more.

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.

TrtnJohn

  • EA User
  • **
  • Posts: 176
  • Karma: +0/-0
    • View Profile
Re: Virtual Method calls in a Sequence Diagram
« Reply #3 on: September 01, 2005, 10:13:48 am »
When showing a generalization, there is only one instance and multiple classes involved.  This is where my confusion comes.  If you want to show the order of virtual method calls you really need a lifeline for each derived class.  But these classes are really only part of a single object instance.  When diagramming use case scenarios the single instance is all that matters.  But, at times, I use the sequence diagram to document code flow.  This is when it would be nice to show the virtual calls.
« Last Edit: September 01, 2005, 10:14:40 am by TrtnJohn »

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Virtual Method calls in a Sequence Diagram
« Reply #4 on: September 01, 2005, 04:08:01 pm »
Sorry I wasn't clear enugh.  I meant that I had to go back through modelling the exact instances to come up with the generalised case.

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.