Book a Demo

Author Topic: Code Generation on self referential aggregation  (Read 3145 times)

nifsmith

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Code Generation on self referential aggregation
« on: February 15, 2006, 01:49:33 pm »
Generating code from EA for a class aggregating itself (having set ArrayList as the default collection for C#) within EA does not generate code to include an ArrayList to hold the self reference.

The code generator will however create an ArrayList to hold a collection if the aggregation is between two different classes.

Also I don't seen to be able to alter (bend line at cursor) or stretch a self referential link to fit.
People should not be afraid of their Governments. Governments should be afraid of their people.

V

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Code Generation on self referential aggregatio
« Reply #1 on: February 15, 2006, 01:53:55 pm »
Quote
Also I don't seen to be able to alter (bend line at cursor) or stretch a self referential link to fit.


FDE!  (Frequently demanded enhancement).

Quote
EA does not generate code to include an ArrayList to hold the self reference.
 Sounds like a problem I'm having myself, could you expand a bit more.

bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code Generation on self referential aggregatio
« Reply #2 on: February 15, 2006, 02:05:03 pm »
Quote

FDE!  (Frequently demanded enhancement).

Now now, young bruce, you know it should be an:

  FRE!  (Frequently requested enhancement)  

You've seen how far demanding has got us...  :-X

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generation on self referential aggregatio
« Reply #3 on: February 15, 2006, 02:50:28 pm »
I'll expand on the code generation issue.

Currently a self-aggregation drawn in the default way will not generate an attribute at all.  There is a fix for this coming, but I don't expect it to come until build 788.

There are a couple of workarounds to the issue that I've found.  

1. Use an association without setting the aggregation on either end.
2. Here's the devious one,  ;) Swap the information in the source role and target role.  I'm guessing that nifsmith's link has the following properties.

Source Role:
- Multiplicity 0..*
- Aggregation none
Target Role:
- Aggregation shared

If you change that to the following it should work as you expect. :)

Source Role:
- Aggregation shared
Target Role:
- Multiplicity 0..*
- Aggregation none