Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Sequence Diagram to Java Code questions
Sequence Diagram to Java Code questions [message #89819] Wed, 03 September 2008 16:42 Go to next message
Hugo Marques is currently offline Hugo MarquesFriend
Messages: 3
Registered: July 2009
Junior Member
Hello,

I am currently developing a tool for generating Java code from UML
sequence diagrams. In this context, I have two doubts and should be
grateful if someone could help me.

Doubts:

1 - Concerning the instantiation of the objects represented by the
lifelines, these objects should be translated a) as attributes from other
objects or b) as parameters taken in the method generated to the sequence
diagram?

2- Concerning control flow of the method. For example, consider a
sequence diagrama named test that has three lifelines ( l1, l2 and l3),
where l1 sends a message msg1() to l2 that in turn sends a message msg2()
to l3. Which would be the correct translation (see the options below) from
this flow to the java code?

a) All messages in the same method but from different classes.
class l1 {
test() {
l2.msg1();
l3.msg2():
}
}

b) All messages in the same method and class.

class l1 {
test() {
self.msg1();
self.msg2();
}
}


c) Messages from different classes and differente methods.
class l1 {
test() {
l2.msg1();
}
}

class l2 {
msg1() {
l3.msg2();
}
}
Thanks in advance for any help,


Best regards,
Hugo Marques
Re: Sequence Diagram to Java Code questions [message #89912 is a reply to message #89819] Thu, 04 September 2008 15:21 Go to previous messageGo to next message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
Thoughts below:

"Hugo Marques" <hugomarques.ufcg@gmail.com> schreef in bericht
news:f5b01d15ec20142bbb49691b6c5b0ce9$1@www.eclipse.org...
>
> Doubts:
>
> 1 - Concerning the instantiation of the objects represented by the
> lifelines, these objects should be translated a) as attributes from other
> objects or b) as parameters taken in the method generated to the sequence
> diagram?

For me it would be logical to have a seperate model input which contains
information about the tool structure, for example a UML class diagram?
If not possible you have to find some way to encode it into your sequence
diagrams. Maybe you can store a reference in the class that calls the
constructor.

> 2- Concerning control flow of the method. For example, consider a
> sequence diagrama named test that has three lifelines ( l1, l2 and l3),
> where l1 sends a message msg1() to l2 that in turn sends a message msg2()
> to l3. Which would be the correct translation (see the options below) from
> this flow to the java code?
>
> a) All messages in the same method but from different classes.
> class l1 {
> test() {
> l2.msg1();
> l3.msg2():
> }
> }
>
> b) All messages in the same method and class.
>
> class l1 {
> test() {
> self.msg1();
> self.msg2();
> }
> }
>
>
> c) Messages from different classes and differente methods.
> class l1 {
> test() {
> l2.msg1();
> }
> }
>
> class l2 {
> msg1() {
> l3.msg2();
> }
> }
> Thanks in advance for any help,

Doesn't this depend on the overlapping of the liftimes, when to create l2
and l3? Does it become clearer if you include constructor calls in your
sequence diagrams?

> Best regards,
> Hugo Marques


Best regards,

Alfons
Re: Sequence Diagram to Java Code questions [message #90096 is a reply to message #89912] Mon, 15 September 2008 17:16 Go to previous message
Hugo Marques is currently offline Hugo MarquesFriend
Messages: 3
Registered: July 2009
Junior Member
Alfons Laarman wrote:

> Thoughts below:

> "Hugo Marques" <hugomarques.ufcg@gmail.com> schreef in bericht
> news:f5b01d15ec20142bbb49691b6c5b0ce9$1@www.eclipse.org...
>>
>> Doubts:
>>
>> 1 - Concerning the instantiation of the objects represented by the
>> lifelines, these objects should be translated a) as attributes from other
>> objects or b) as parameters taken in the method generated to the sequence
>> diagram?

> For me it would be logical to have a seperate model input which contains
> information about the tool structure, for example a UML class diagram?
> If not possible you have to find some way to encode it into your sequence
> diagrams. Maybe you can store a reference in the class that calls the
> constructor.

>> 2- Concerning control flow of the method. For example, consider a
>> sequence diagrama named test that has three lifelines ( l1, l2 and l3),
>> where l1 sends a message msg1() to l2 that in turn sends a message msg2()
>> to l3. Which would be the correct translation (see the options below) from
>> this flow to the java code?
>>
>> a) All messages in the same method but from different classes.
>> class l1 {
>> test() {
>> l2.msg1();
>> l3.msg2():
>> }
>> }
>>
>> b) All messages in the same method and class.
>>
>> class l1 {
>> test() {
>> self.msg1();
>> self.msg2();
>> }
>> }
>>
>>
>> c) Messages from different classes and differente methods.
>> class l1 {
>> test() {
>> l2.msg1();
>> }
>> }
>>
>> class l2 {
>> msg1() {
>> l3.msg2();
>> }
>> }
>> Thanks in advance for any help,

> Doesn't this depend on the overlapping of the liftimes, when to create l2
> and l3? Does it become clearer if you include constructor calls in your
> sequence diagrams?

>> Best regards,
>> Hugo Marques


> Best regards,

> Alfons

First of all, thanks for the help, about the question 1 we suspected that
we could need another model, i was simply trying to avoid the use of this
model, but it seems it the logical solution.
About question 2, sorry but i didnŽt understood what did you mean, could
you explain with other words? Trying to explain to problem a bit more, i
already have these 3 objects created, my doubts are about the method flow
between then, honestly i think itŽs the option A but iŽm not sure.

Thanks in advance
Hugo Marques
Previous Topic:[ATL] creating objects in ATL
Next Topic:Loading ATL programmatically. PackageNotFoundException
Goto Forum:
  


Current Time: Fri Apr 26 11:41:45 GMT 2024

Powered by FUDForum. Page generated in 0.03374 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top