Author Topic: <<new>> message implies end of lifecyc  (Read 1455 times)

Erik Finnegan

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
<<new>> message implies end of lifecyc
« on: March 31, 2004, 01:00:03 pm »
Hi all,

in a sequence diagram, when I am modeling the creation of a new object with the message of lifecycle type <<new>>, it seems to always imply the destruction of the object at the end of its activation layer, i.e. the dotted life line ends in an "X" after the last outgoing call.

How can I make the lifeline go through until the end of the diagram (just like any other object in the diagram) to indicate the ongoing existence of that newly created object instance?

I appreciate your help.


Erik

andro

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: <<new>> message implies end of lif
« Reply #1 on: March 31, 2004, 02:10:34 pm »
Hi Erik.
I don't think I'm gonna help you, as I'm also a newbie.  I wonder though what could be the purpose of having the object existing until the end of the sequence, if you don't use it anymore. In other words, if you need it, there's surely a message to be sent to it or to come out of it, and if you draw such a message, the destruction point will be moved after it, right?
andro.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: <<new>> message implies end of lif
« Reply #2 on: March 31, 2004, 06:21:40 pm »
I think Erik's problem is that the destruction of the object ( the X) is not moveable.

Consider:
1 User starts app (invoke new static Main::Thread)
2. Main creates new object MyMenu::Menu
3. MyMenu creates a set of menuitems and adds them to itself (call new MyMenuItem::MenuItem.AddItem)
4. User clicks on a menu item (call MyMenuItem[x].Click)
5*. Repeat 4 until menu item clicked is "Exit"
6. MyMenuItem("Exit").Click handler calls Main.Exit (lifecycle = delete)

The "X" denoting the extinction of the MyMenu object is located just after message 3.

This is misleading as the MyMenu object still exists until the Main.Exit call and could possibly enter into another interaction.  Fine if you are puttin that interaction in now, i.e. the day you created the diagram.  Now come back 3 months later and try and decipher why the MyMenu object seems to be destroyed so early in the timeline.

In short, I agree with Erik.  However, I dont know whether EA or UML is at fault - if I get time I'll go back to that damn UML 2 spec document and check.

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.

mbc

  • EA User
  • **
  • Posts: 237
  • Karma: +1/-0
  • Embedded software developer
    • View Profile
Re: <<new>> message implies end of lif
« Reply #3 on: March 31, 2004, 11:41:26 pm »
In EA 3.6 you go to:
"Tools - Options - Diagram - Sequence" and uncheck GarbageCollect. If you are using version 4, look for a similar option. I don't have that version on this computer, so I can't check.
I have experienced that this option doesn't always affect existing diagrams, but you will have to fiddle around a bit with that.

Mikkel

mbc

  • EA User
  • **
  • Posts: 237
  • Karma: +1/-0
  • Embedded software developer
    • View Profile
Re: <<new>> message implies end of lif
« Reply #4 on: March 31, 2004, 11:49:10 pm »
For andro:

There are several reasons why you might want to keep the object past the end of the diagram.

One is that an object may take part in so many interactions that it would take a kilometer high sequence diagram to fit them all in. In this case it makes more sense to group the interactions in several separate diagrams.

Another is if the object is just never destroyed. For example a statically allocated object. When you work with small embedded systems like me, most of your objects might be statically allocated.

The third is that if you don't program for an environment with automatic garbage collection, you will probably not want objects to vanish into thin air by themselves. An important task in programming is to remember to destroy everything that you create, so it makes sense to want to specify destruction explicitly (a message with Lifecycle set to Delete).

Best regards,
Mikkel


andro

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: <<new>> message implies end of lif
« Reply #5 on: April 01, 2004, 11:41:29 am »
Thanks for the lesson, Mikkel.
I've just come across another UML tool - SDE from Visual Paradigm.  I tried the case in SDE and the object wasn't destroyed after its last message, which only proves you are right.
By the way, have you heard of SDE? How does it compare to EA?
Best regards,
andro.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: <<new>> message implies end of lif
« Reply #6 on: April 01, 2004, 02:40:10 pm »
Quote
"Tools - Options - Diagram - Sequence" and uncheck GarbageCollect


Yep - its there and it works fine!

Thanks MBC - I guess its one of those set and forget options that I forget when I built my ver 4 profile.

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.