Book a Demo

Author Topic: Specifying collection return type for an operation  (Read 5586 times)

Gusztav

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
  • EA expert
    • View Profile
    • Imprestige. Your issues in safe hands.
Specifying collection return type for an operation
« on: September 18, 2013, 11:06:07 pm »
Anyone a tip on how to set the return type of an operation in a class to be a collection rather than array? This can be done with attribute types and operation parameter types, but method return types do not support it – or I'm missing something.

The only way I can think of is to customize MDA/code templates to add "List>" and ">" around types with multiplicity > 1, but this is not an elegant solution.
------------------------
Imprestige. Your issues in safe hands.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Specifying collection return type for an opera
« Reply #1 on: September 19, 2013, 12:35:12 am »
Hi,

an easy way to check the code generation features is to make a simple code example in your language. Than import it with EA and you can see what EA makes from the code.

Helmut

Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Gusztav

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
  • EA expert
    • View Profile
    • Imprestige. Your issues in safe hands.
Re: Specifying collection return type for an opera
« Reply #2 on: September 19, 2013, 12:44:21 am »
Hi Helmut,

This is true, however it's a bit more experimental than desired; what if you are not prepared for an unforeseen scenarion in the code? But actually, the bigger issue is that I'd be particularly interested in configuring this for transforming a domain model to a C# model. To conform to RUP and other principles, in the domain model you should not concern with the data structure used to store a collection of values; it is rather okay to call it array. However the heart of implementation design and the supporting C# model transformation is to transform UML data types/syntax to C#.

To response to your suggestion more precisely: EA will define the return type as List<Foo> when reverse engineering a method with List<Foo> return type. However in case of List<Foo> return type in EA, EA will not recognize Foo is part of the semantics of the model, so if you rename your Foo type in your model, List<Foo> will remain intact as a return type (but if it were only Foo, it would be renamed to the new name). Similarly, when generating code from a type like List<Foo>, EA won't know what namespace to specify for Foo, 'cuse it will only be a char literal for EA.

So I'm afraid checking the results of reverse engineering does not answer the conceptual part of the question, and yields in a data type EA will not handle as expected.
------------------------
Imprestige. Your issues in safe hands.