Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to specialize the aggregation for code-generation
icon5.gif  How to specialize the aggregation for code-generation [message #520867] Mon, 15 March 2010 15:52 Go to next message
Konstantin is currently offline KonstantinFriend
Messages: 8
Registered: March 2010
Location: Germany
Junior Member
Hi all!

I'm not so experienced in using of UML. I've learned how to read it, but I'm not sure how to use it for model driven development.

Assuming we have to model the Sudoku field generator and we have noticed, that we have two following classes: SudokuField and LineConstraint.
The LineConstraint instances cannot exist without a bound SudokuField. So we add an association with one composite end.
Each SudokuField is associated with severally LineConstraints.

After a while we'd like to produce the source code for it and to get a field with List<LineConstraint> type in the SudokuField class. But we don't want to remove the association with the LineConstraint.

Do someone have idea how to express this?

I could imagine that the association-class could be the right choice. The association-class could be the List_LineConstraint with the template binding connection to the List<E>. And the association with class should be set as specification of the composite association...

I'm glad to see your opinions.
Re: How to specialize the aggregation for code-generation [message #520879 is a reply to message #520867] Mon, 15 March 2010 11:24 Go to previous messageGo to next message
Erhard Weinell is currently offline Erhard WeinellFriend
Messages: 39
Registered: January 2010
Location: Kassel, Germany
Member
Konstantin,

Am 15.03.2010 16:52, schrieb Konstantin:

> After a while we'd like to produce the source code for it and to get a
> field with List<LineConstraint> type in the SudokuField class.

Depending on your favourite UML tool, the code generator can be
configured to generate this code (e.g. using templates).

> But we don't want to remove the association with the LineConstraint.

It's only a matter of how code is generated from your diagram - why
would this inflict changes to the diagram? (that's what I understood)

> I could imagine that the association-class could be the right choice.
> The association-class could be the List_LineConstraint with the template
> binding connection to the List<E>. And the association with class should
> be set as specification of the composite association...

Strictly no. Are you trying to model a class "List" in your diagram? As
I said, such implementation detail should be left to the code generator.

Best,
Erhard
Re: How to specialize the aggregation for code-generation [message #520975 is a reply to message #520867] Tue, 16 March 2010 01:56 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Konstantin wrote on Mon, 15 March 2010 11:52

The LineConstraint instances cannot exist without a bound SudokuField. So we add an association with one composite end.
Each SudokuField is associated with severally LineConstraints.

After a while we'd like to produce the source code for it and to get a field with List<LineConstraint> type in the SudokuField class. But we don't want to remove the association with the LineConstraint.

Do someone have idea how to express this?



Erhard is right, you have done everything right, no further action required, as multiple properties are ordered by default. See "Mapping UML multiplicities to Java" in the TextUML Toolkit wiki:

http://sourceforge.net/apps/mediawiki/textuml/index.php?titl e=UML_101#Multiplicity

Of course, it is up to your template/code generator to honor the multiplicity properly.

Cheers,

Rafael
http://abstratt.com/blog
Re: How to specialize the aggregation for code-generation [message #521214 is a reply to message #520867] Tue, 16 March 2010 18:25 Go to previous messageGo to next message
Konstantin is currently offline KonstantinFriend
Messages: 8
Registered: March 2010
Location: Germany
Junior Member
Thanks to all for quick answer.

I'm trying the TopCased.

It's not so easy to generate a source code from Model there. I'm not ready with this yet.

My problem is, that I've used parts of UML 1.x before and I'm able to read models (I guess), but I never could generate a suitable source code from the model. That is something I'd like to learn.

Most of the free-ware tools I've worked with were not good/flexible/comfortable enough. And I was not ready to pay for something I cannot use efficiently.

So I want to try UML for MDD with free-ware tools again and the TopCased appears to be the right choice.

[Updated on: Tue, 16 March 2010 18:26]

Report message to a moderator

Re: How to specialize the aggregation for code-generation [message #521495 is a reply to message #521214] Wed, 17 March 2010 19:01 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
You might want to take a look at this code generation article using Xpand:

http://www.peterfriese.de/getting-started-with-code-generati on-with-xpand/

It's not UML specific though, by can be adapted to work with UML2 instead of using a custom metamodel.
Re: How to specialize the aggregation for code-generation [message #522686 is a reply to message #520867] Tue, 23 March 2010 10:36 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Konstantin

You may want to have a look at this article on the Wiki:
http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Defin ing_Generics_with_UML_Templates/article.html

Cheers,
- James.

"Konstantin" <tkachenkok@gmx.de> wrote in message
news:hnll4g$gls$1@build.eclipse.org...
> Hi all!
>
> I'm not so experienced in using of UML. I've learned how to read it, but
> I'm not sure how to use it for model driven development.
>
> Assuming we have to model the Sudoku field generator and we have noticed,
> that we have two following classes: SudokuField and LineConstraint. The
> LineConstraint instances cannot exist without a bound SudokuField. So we
> add an association with one composite end. Each SudokuField is associated
> with severally LineConstraints.
>
> After a while we'd like to produce the source code for it and to get a
> field with List<LineConstraint> type in the SudokuField class. But we
> don't want to remove the association with the LineConstraint.
>
> Do someone have idea how to express this?
>
> I could imagine that the association-class could be the right choice. The
> association-class could be the List_LineConstraint with the template
> binding connection to the List<E>. And the association with class should
> be set as specification of the composite association...
>
> I'm glad to see your opinions.
Re: How to specialize the aggregation for code-generation [message #522897 is a reply to message #522686] Wed, 24 March 2010 12:28 Go to previous messageGo to next message
Konstantin is currently offline KonstantinFriend
Messages: 8
Registered: March 2010
Location: Germany
Junior Member
Hi James,

Thanks for advice.

I've looked at this article before writing the post. I haven't got all of the things there. Embarrassed

I'm not sure, why is the concept of generics so complex in UML. I'm new to profiling. ECore is an UML profile. But what is advantage of using it? Should I use it? How can I use it? ...
So I've decided to learn by doing.
But the attempt was not successfull.

I've made simple Java project with two classes:
public class SudokuField {	
	private List<LineConstraints> lineConstraints;
	SudokuField() { ... }
	public static void main(String[] args) { ... }
}

public class LineConstraints {
	public static void main(String[] args) { ...	}
	public void SayHallo() { ...}
}

And then I've converted it to the uml model (Using UML from Java). But the result of it disappointed me:
<Class> SudokuField
  <Property> lineConstraints : List


The information about the generics was not there... Sad

So I have something to learn about, before I'm ready to use such a tools...

I think, I'll start with the exploring the ECore...
Re: How to specialize the aggregation for code-generation [message #522933 is a reply to message #522897] Wed, 24 March 2010 14:57 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Konstantin, unless the code generation tools you use require you to use UML templates to generate Java code with generics, I would stay away from it. UML templates are a much more powerful concept than Java generics, and are intended for different purposes.

If all you want to do is to be able to use Java generics in multivalued relationships (with collections), using UML templates is using a cannon ball to kill a fly (no to mention it smells like bringing implementation concerns to your models).

Generating Java code with generics in collection elements really does not require any information you don't have already in a regular property element.

Cheers,

Rafael

[Updated on: Wed, 24 March 2010 14:58]

Report message to a moderator

Re: How to specialize the aggregation for code-generation [message #522946 is a reply to message #522897] Wed, 24 March 2010 15:10 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Konstantin

I'm not sure what tool you are using to go from Java to UML but it sounds
like it's missing the generics part.

The simplest way to start is with an Ecore model. Define all your generics
in Ecore; make sure you can generate the kind of Java code you want. You
can then convert from Ecore to UML if you want to get the UML representation
(by using the Ecore to UML converter provided by the UML2 project ).

I totally agree that UML is very tricky and verbose.
Ecore is more compact and more intuitive if you are using it to generate
code.

Cheers,
- James.

"Konstantin" <tkachenkok@gmx.de> wrote in message
news:hod0hi$iq$1@build.eclipse.org...
> Hi James,
>
> Thanks for advice.
> I've looked at this article before writing the post. I haven't got all of
> the things there. :blush:
> I'm not sure, why is the concept of generics so complex in UML. I'm new to
> profiling. ECore is an UML profile. But what is advantage of using it?
> Should I use it? How can I use it? ...
> So I've decided to learn by doing.
> But the attempt was not successfull.
>
> I've made simple Java project with two classes:
>
> public class SudokuField { private List<LineConstraints> lineConstraints;
> SudokuField() { ... }
> public static void main(String[] args) { ... }
> }
>
> public class LineConstraints {
> public static void main(String[] args) { ... }
> public void SayHallo() { ...}
> }
>
> And then I've converted it to the uml model (Using UML from Java). But the
> result of it disappointed me:
>
> <Class> SudokuField
> <Property> lineConstraints : List
>
>
> The information about the generics was not there... :(
>
> So I have something to learn about, before I'm ready to use such a
> tools...
>
> I think, I'll start with the exploring the ECore...
Re: How to specialize the aggregation for code-generation [message #628329 is a reply to message #521214] Wed, 17 March 2010 19:01 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
You might want to take a look at this code generation article using Xpand:

http://www.peterfriese.de/getting-started-with-code-generati on-with-xpand/

It's not UML specific though, by can be adapted to work with UML2 instead of using a custom metamodel.
Previous Topic:Storing aggregation property in .uml file
Next Topic:How to specialize the aggregation for code-generation
Goto Forum:
  


Current Time: Tue Mar 19 14:04:20 GMT 2024

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

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

Back to the top