Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Best Java generation tool from UML in Eclipse
Best Java generation tool from UML in Eclipse [message #1750138] Fri, 16 December 2016 10:49 Go to next message
Víctor López is currently offline Víctor LópezFriend
Messages: 22
Registered: June 2014
Junior Member
Hi all!,
I wonder if someone could provide some insights about what is the best Java code generation tool in Eclipse (from UML models built using Papyrus).
So far, the ones I have tested are really buggy and incomplete.

Best,

Víctor
Re: Best Java generation tool from UML in Eclipse [message #1750149 is a reply to message #1750138] Fri, 16 December 2016 12:33 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Please have a look at our presentation at EclipseCon Europe: http://www.slideshare.net/kthoms/recipes-to-build-code-generators-for-nonxtext-models-with-xtend
Sample projects here: https://github.com/kthoms/xtend-codegen-examples

~Karsten
Re: Best Java generation tool from UML in Eclipse [message #1750150 is a reply to message #1750149] Fri, 16 December 2016 13:01 Go to previous messageGo to next message
Víctor López is currently offline Víctor LópezFriend
Messages: 22
Registered: June 2014
Junior Member
Hi Karsen,
Your interesting talk slides are more about the features of XTEXT rather than about a ready-to-use solution for Java code generation.
I'm searching for solutions already developed, since I don't feel it is a custom need, but a general solution.

Best,

Víctor

Karsten Thoms wrote on Fri, 16 December 2016 13:33
Please have a look at our presentation at EclipseCon Europe: http://www.slideshare.net/kthoms/recipes-to-build-code-generators-for-nonxtext-models-with-xtend
Sample projects here: https://github.com/kthoms/xtend-codegen-examples

~Karsten

Re: Best Java generation tool from UML in Eclipse [message #1750152 is a reply to message #1750150] Fri, 16 December 2016 13:28 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You give no indication on the kind of Java code you want.

If you just require class structure, UML2Ecore will enable you to get standard EMF Java generation to do good things.

You can enrich your UML model with OCL constraints and bodies and these should propagate through UML2Ecore into the Java. You can choose interpreted OCL or use OCL2Java to embed direct Java code.

If you require state machines or other advanced UML facilities, you need to look at 'real' UML code generators. I'm not aware of any that have exploited the OCL2Java capabilities.

Regards

Ed Willink
Re: Best Java generation tool from UML in Eclipse [message #1750253 is a reply to message #1750152] Mon, 19 December 2016 10:33 Go to previous messageGo to next message
Víctor López is currently offline Víctor LópezFriend
Messages: 22
Registered: June 2014
Junior Member
Hi Ed,
Actually what I'm aiming to is just class generation from UML class diagrams.
This generation should include classes, attributes, methods (including constructors) and those attributes and methods derived from the relationships.

Best,

Víctor

Ed Willink wrote on Fri, 16 December 2016 14:28
Hi

You give no indication on the kind of Java code you want.

If you just require class structure, UML2Ecore will enable you to get standard EMF Java generation to do good things.

You can enrich your UML model with OCL constraints and bodies and these should propagate through UML2Ecore into the Java. You can choose interpreted OCL or use OCL2Java to embed direct Java code.

If you require state machines or other advanced UML facilities, you need to look at 'real' UML code generators. I'm not aware of any that have exploited the OCL2Java capabilities.

Regards

Ed Willink

Re: Best Java generation tool from UML in Eclipse [message #1750258 is a reply to message #1750253] Mon, 19 December 2016 11:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

UML2Ecore should suit you well. NB there is only a default constructor, since EMF imposes default construction then property-by-property assignment in order to support generic loading from XML.

You can add Java bodies manually. Or you can use OCL definitions within your OCL, or merged from a separate OCL document. The OCL tooling is autogenerated from a UML class structure model and an OCL document defining invariants. The OCL2Java in principle supports all normal OCL (no @pre, oclIsNew, oclIsInState) but as I use it more and more, I steadily find bugs to fix.

Regards

Ed Willink
Re: Best Java generation tool from UML in Eclipse [message #1750260 is a reply to message #1750258] Mon, 19 December 2016 11:17 Go to previous messageGo to next message
Víctor López is currently offline Víctor LópezFriend
Messages: 22
Registered: June 2014
Junior Member
Thanks Ed, I will give it a try.

Ed Willink wrote on Mon, 19 December 2016 12:12
Hi

UML2Ecore should suit you well. NB there is only a default constructor, since EMF imposes default construction then property-by-property assignment in order to support generic loading from XML.

You can add Java bodies manually. Or you can use OCL definitions within your OCL, or merged from a separate OCL document. The OCL tooling is autogenerated from a UML class structure model and an OCL document defining invariants. The OCL2Java in principle supports all normal OCL (no @pre, oclIsNew, oclIsInState) but as I use it more and more, I steadily find bugs to fix.

Regards

Ed Willink

Re: Best Java generation tool from UML in Eclipse [message #1750261 is a reply to message #1750253] Mon, 19 December 2016 11:18 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

What kind of classes would you expect? While "normal" classes could be translated to POJOs that is usually not what you'd expect. Normally code generation from UML makes more sense when it is domain specific, with a profile. Then a class could be mapped to some persistent technology, like Hibernate or whatever. Or how would you map relationship kinds aggregation vs. composite? This is semantically a huge difference, while its implementation might be different approaches possible.

A simple "translate UML to Java" approach is just naive and does not have any benefit in practice. That is also why you won't find good approaches.

If you would start to describe a mapping from UML to Java you will very soon experience that this is too ambiguous how an implementation would look like, especially if you don't work with a proper profile.
Re: Best Java generation tool from UML in Eclipse [message #1750266 is a reply to message #1750261] Mon, 19 December 2016 11:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Karsten Thoms wrote on Mon, 19 December 2016 06:18
A simple "translate UML to Java" approach is just naive and does not have any benefit in practice. That is also why you won't find good approaches.


Indeed. If you are after production quality code with interesting structure you may well benefit from using some form of M2T. The basic structure is very easy and automating your interesting structure can be very beneficial.

[Of course, if you're happy to be bleeding edge, M2M can be even better and the autogenerated Java code from Eclipse QVTr is just beginning to cross the credibility threshold.]

Regards

Ed Willink
Re: Best Java generation tool from UML in Eclipse [message #1750267 is a reply to message #1750261] Mon, 19 December 2016 11:52 Go to previous message
Víctor López is currently offline Víctor LópezFriend
Messages: 22
Registered: June 2014
Junior Member
Hi,
It's true that generating domain specific classes with profiles is more useful, but I don't feel like POJOs are useless, because sometimes you don't want to use a framework. Even for generating POJOs a profile is needed, that's what I'm missing. Also, if you plan to generate code for a specific framework you will probably need most of the POJO generation part.
To me it's quite clear the difference between aggregation and composition in Java code generation. For instance, you can take a look at:
http://stackoverflow.com/questions/11881552/implementation-difference-between-aggregation-and-composition-in-java

Best,

Víctor

Karsten Thoms wrote on Mon, 19 December 2016 12:18
What kind of classes would you expect? While "normal" classes could be translated to POJOs that is usually not what you'd expect. Normally code generation from UML makes more sense when it is domain specific, with a profile. Then a class could be mapped to some persistent technology, like Hibernate or whatever. Or how would you map relationship kinds aggregation vs. composite? This is semantically a huge difference, while its implementation might be different approaches possible.

A simple "translate UML to Java" approach is just naive and does not have any benefit in practice. That is also why you won't find good approaches.

If you would start to describe a mapping from UML to Java you will very soon experience that this is too ambiguous how an implementation would look like, especially if you don't work with a proper profile.

Previous Topic:Cross-reference not found
Next Topic:Path src-gen variable
Goto Forum:
  


Current Time: Sat Apr 20 15:31:36 GMT 2024

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

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

Back to the top