Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Destroying object in sequence diagram

 
vu lee
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My search logic is as following
1. use DAO to query data, create a Transfer Object (TO) named EmployeeTO, and then redirect this TO to a JSP page
2. use DAO to query data again based on the user select on the previous JSP page, create a new EmployeeTO object, and redirect this object to JSP page.

How do I show that the first TO has been destroyed before the second TO is created in the sequenc diagram. Thanks
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Destroying an object is shown by a cross across the lifeline of an object. See figure 4 at http://www.agilemodeling.com/artifacts/sequenceDiagram.htm for exmaple.

Does that help?
 
vu lee
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does. Thanks Ilja

I am using MagicDraw to draw the sequence diagram. Per my knowledge, the only way I can destroy an object is to send the message of type 'destroy' to the object. In my case, the JSP page uses TO which then be ready for garbage collection. In the reference diagram, I see that an X is used to indicate the object has been destroyed (there is no need to send destroy message to the object). Suppose my current MagicDraw does not support marking an X, how do I represent this in my sequence diagram.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, the joy of UML software.

The only advice I can give you is to use a more low-level tool - a general purpose drawing program like Visio, perhaps UMLet or even pencil and paper or a white board...
 
Scott Ambler
author
Ranch Hand
Posts: 608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't worry about it. As I indicate at UML Sequence Diagramming Guidelines the X is largely unneccessary. If you're writing code in Java you don't have control over object destruction due to garbage collection. If you're using a language such as C++ that doesn't have garbage collection then the programmers very likely have a much better understanding of memory management than you do, so the X will be ignored because they'll simply do the right thing.

My advice is to keep your models as simple as possible. You don't need to put in all the details, you just need models which are Good Enough.

- Scott
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic