Sparx Systems Forum

Discussion => Uml Process => Topic started by: jepessen on June 28, 2016, 08:33:13 pm

Title: [Sequence Diagram] Setting an object to another object
Post by: jepessen on June 28, 2016, 08:33:13 pm
This is my situation:


I want to create a sequence diagram in which I set an instance of Sink (named ConsoleSink) and then pass it as argument of my Configuration class instance.

This is what I've done:

(https://s32.postimg.org/gbwwqrxud/Console_Sink.png)

I don't know if I'm doing it correctly. I want to show in Sequence digram first that I create and set the Sink class instance, and then I pass it as argument in Configuration class instance.

This is the correct way to do it?
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: Geert Bellekens on June 28, 2016, 08:43:34 pm
No, you should drag your classes onto the diagram as lifelines, and name them (now the lifelines are unnamed isntances of classes that might not exist)

Also don't use the «create» stereotype, but set the lifecycle property to New in your message.
and using an Actor call Program is also not what I would do.

I have documented some of my best practices regarding sequence diagrams here: UML Best Practice: One Operation => One Sequence Diagram (https://bellekens.com/2011/05/27/uml-best-practice-one-operation-one-sequence-diagram/)

Geert
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: qwerty on June 28, 2016, 08:48:08 pm
To me that looks ok. I would not use a <<create>> but rather set the Lifecycle to New in the properties of the first message. (Oh, I see that Geert mentioned that already)

q.
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: jepessen on June 28, 2016, 09:09:45 pm
Ok I've set the lifecycle property and set lifelines (they were already lifelines, but unnamed).

Now this is the diagram:

(https://s32.postimg.org/f43cnr02t/Console_Sink2.png)

I don't know if it's correct that the lifeline if the Sink objects ends before I set it to Configuration instance. I've tried to increase the length if ConsoleSink lifeline but with no result. What I should do now?
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: Geert Bellekens on June 28, 2016, 09:29:23 pm
There 's an option somewhere that controls the automatic "destruction"of objects.

Still seems weird to me that you would call the constructor Sink() on a class ConsoleSink(). Isn't the constructor supposed to have the same name as the class? (in most programming languages I know)

Geert
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: qwerty on June 28, 2016, 10:54:57 pm
Tools/Options/Diagram/Sequence/Garbage... (right middle)

Heaven knows where this in the ribbons.

q.
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: jepessen on June 28, 2016, 11:12:02 pm
I've found the garbage option and it's enabled, so with this option active I obtain the last diagram.
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: jepessen on June 28, 2016, 11:16:01 pm
I've disabled the GarbageCollect (autodelete) option and now this is the diagram (I've also fixed the name of the object passed to Configuration instance):

(https://s32.postimg.org/41p1airo5/Console_Sink.png)

It's correct now or there's something else that I must fix?
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: qwerty on June 28, 2016, 11:33:23 pm
Just remove the name from the New method call. So it is explicit.

q.
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: jepessen on June 28, 2016, 11:40:48 pm
But in the constructor (ok, the name is wrong) I put an ID, there's not a default constructor. Can I omit it in UML logic?
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: qwerty on June 29, 2016, 01:40:52 am
Just leave the name empty. Since it is a constructor call, it is implicit.

q.
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: jepessen on June 29, 2016, 01:49:20 am
Ok thanks.
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: Uffe on August 22, 2016, 08:26:18 pm
This question is not related to the original post. Please delete it and repost in its own thread.

/Uffe
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: qwerty on August 22, 2016, 08:52:00 pm
Hehe. We're not on SO here xD

q.
Title: Re: [Sequence Diagram] Setting an object to another object
Post by: bockfu on August 28, 2016, 05:44:25 am
I encourage you to consider updating the diagram based on Geerts blog post and generalize the trigger/calling behavior by using a gate.  I've applied this practice and find it useful.   This is one thing I encourage you to get familiar with, the earlier the better.

I also get the impression the operations for the class are not defined.    Since it appears The lower level details are valuable, you may want to consider stubbing out the class. This way the operation names will become available in a drop down menu when making call associations across lifelines.  I think this would help align the diagram with the specific behavior, automate the alignment between the class definition and diagram, and ultimately help you narrow in on a model definition that makes the most sense.

Just my thoughts.