Page 1 of 1

Code Generation from Stereotypes

PostPosted: Mon 5 Jun 2017 20:25
by Arg
Hi
I am new to BOUML so it is possible I have missed this.
I want to extend UML using stereotypes so that when I assign a stereotype to a particular element the code that is generated for the element can be modified by the assigned stereotype.
At first look this seems possible, but I can only see this for the existing stereotypes. It does not seem possible to extend the stereotypes with user stereotypes for the purpose of code generation.
Am I missing something

Example
I would like to extend an Operation with the stereotype <<log>> that would surround the "body" code with a pair of longing function calls. Whilst leaving the other operations without the stereotype with the default generated code.

Thanks

Re: Code Generation from Stereotypes

PostPosted: Mon 5 Jun 2017 21:25
by Bruno Pagès
Hi,

This is possible, some topics to know :

Kind regards
Bruno Pagès

Re: Code Generation from Stereotypes

PostPosted: Mon 5 Jun 2017 22:43
by Arg
Hi, Thanks for the quick reply
My thoughts on the solutions you suggest.

1st point I think I got, but this would require me to modify each operation by hand. Not the idea I could just add it to the code.
2nd point requires me to write a plugout. Would be better but I would have to change the plugout when I wanted to modify the code
3rd point is probably the closest solution. To write a plugout that allows me to configure the code generation sections in my stereotype, and when they are applied to the element the elements code generation sections will be replaced by those in the stereotype. If this is possible.

This would then allow the user to configure the code generation within the model.
I must say I am surprised that this does not already exist as it would improve the versatility of your program considerably. It would allow Bouml to be used for simple DSL (Domain Specific Language) without the need for additional programming.

I will need to think about this. It is more work than I expected.

Re: Code Generation from Stereotypes

PostPosted: Tue 6 Jun 2017 06:57
by Bruno Pagès
Hi,

It seems I wasn't clear but the first and second topics I mentioned was just present to introduce required material to understand the third topic being the answer to your problem ;)

Re: Code Generation from Stereotypes

PostPosted: Wed 30 Aug 2017 13:21
by joan
Hello,

I would also vote for customizable code generation based on stereotype ;-)

Joan

Re: Code Generation from Stereotypes

PostPosted: Wed 30 Aug 2017 15:23
by Bruno Pagès
Hello,

As I said associating plug-out(s) to the stereotypes (part of profile) you can automatically set the artifact/class/operation/attribute/relation definition/declaration to generate the code you expect

What is the problem ?

Re: Code Generation from Stereotypes

PostPosted: Wed 30 Aug 2017 18:32
by joan
There is only one problem - the time for learning and writing plug-outs :)

Re: Code Generation from Stereotypes

PostPosted: Wed 30 Aug 2017 19:47
by Bruno Pagès
it is easy, you have tutorial to have an idea of that