Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: José Farinha on September 10, 2022, 04:05:54 am

Title: Transformation macros: user defined?
Post by: José Farinha on September 10, 2022, 04:05:54 am
Is it possible to create new, user-defined transformation macros?

I've read 16.0's documentation  and checked EA itself, but couldn't find anything.

For instance, I'd like to have a macro for transforming names from singular to plural and customize the DDL transformation to get something like this:

   name=%qt%%CONVERT_NAME(PLURAL(className), "Spaced", "Underscored")%%qt%

Note: simply appending an 's' doesn't suffice, since languages such as Portuguese and French have complex plural rules as well as special cases.

(I'm not sure if this is the right board for this question. Apologize if it isn't)

Thanks a lot

Title: Re: Transformation macros: user defined?
Post by: qwerty on September 10, 2022, 05:48:02 am
Just my opinion (whatever it might count): don't use them at all. Transformation sounds nice but the process is questionable. if you have a model and a derived one, there's usually a part that won't transform with simple rules. So you have to do that manually. Means you have two branches which somehow are linked. Also you usually adapt that transformed part to satisfy requirements in the one or other way (plus you have the backward way also quite often!). In the end you have two (cross-)dependent branches but there is no easy way to get changes from the base model into the transformed one. The only way I found was by manually synchronizing both and using "natural communication" to achieve that. EA's transformation also create lots of (invisible) dependencies which did not really help maintaining a synchronization (just because that is not trivial).

q.
Title: Re: Transformation macros: user defined?
Post by: Eve on September 12, 2022, 07:51:37 am
Yes, there is a mechanism.

Code: [Select]
$plural=%EXEC_ADD_IN("MyAddin", "Plural", className)%
name=%qt%%CONVERT_NAME($plural, "Spaced", "Underscored")%%qt%

https://sparxsystems.com/enterprise_architect_user_guide/16.0/modeling_domains/functionmacros.html (https://sparxsystems.com/enterprise_architect_user_guide/16.0/modeling_domains/functionmacros.html)

Just for the record, I wouldn't go near writing this function if I could avoid it. Even if it was just for English it is always going to be incomplete. That may be okay if the people writing it are the same people running it, but for something like EA you could be waiting months just to get one special case added.
Title: Re: Transformation macros: user defined?
Post by: José Farinha on September 13, 2022, 12:05:49 am
Just my opinion (whatever it might count): don't use them at all. Transformation sounds nice but the process is questionable. if you have a model and a derived one, there's usually a part that won't transform with simple rules. So you have to do that manually. Means you have two branches which somehow are linked. Also you usually adapt that transformed part to satisfy requirements in the one or other way (plus you have the backward way also quite often!). In the end you have two (cross-)dependent branches but there is no easy way to get changes from the base model into the transformed one. The only way I found was by manually synchronizing both and using "natural communication" to achieve that. EA's transformation also create lots of (invisible) dependencies which did not really help maintaining a synchronization (just because that is not trivial).

q.

Thanks for the advice, Querty.

I'm aware of the challenges of keeping models aligned. But I just want to forward engineer a pack of models I have and the macro I mentioned would save some work.

Best regards
Title: Re: Transformation macros: user defined?
Post by: José Farinha on September 13, 2022, 12:13:02 am
Yes, there is a mechanism.

Code: [Select]
$plural=%EXEC_ADD_IN("MyAddin", "Plural", className)%
name=%qt%%CONVERT_NAME($plural, "Spaced", "Underscored")%%qt%

https://sparxsystems.com/enterprise_architect_user_guide/16.0/modeling_domains/functionmacros.html (https://sparxsystems.com/enterprise_architect_user_guide/16.0/modeling_domains/functionmacros.html)

Just for the record, I wouldn't go near writing this function if I could avoid it. Even if it was just for English it is always going to be incomplete. That may be okay if the people writing it are the same people running it, but for something like EA you could be waiting months just to get one special case added.

Thanks, Eve.
I'll check it out. Looks feasible.

Best regards.