Book a Demo

Author Topic: Aggregation Modelling  (Read 4528 times)

Cosmo Nova

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Aggregation Modelling
« on: March 17, 2008, 02:32:56 pm »
Hi all, I was trying to draw a class diagram, where a class owns some other classes... and thus I applied the aggregation relations. I got TWO questions about this aggregation:

1. When I generated code from the class diagram, it created a poiner as member variable in the owner class. I got the same result no matter it's an aggregation or composition. How can I differentiate them in code generation?

2. When I use reverse engineering to generate class diagram, from the code just generated, I got a different diagram... The main problem is I lost ALL the aggregation relations, and they becomes normal "association" between the two classes.. The code reverse engineering supposed to be very useful when I modified the code and update the diagram through the code. How can I preserve the aggregation relations through settings or whatever?

EA is a great tool! Thanks a lot!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Aggregation Modelling
« Reply #1 on: March 17, 2008, 10:25:28 pm »
Hey Cosmo,

There was some very good information on EA's implementation of these relationships quite a while back. The threads in question were started - I think - by Paolo Cantoni (in one of his incarnations, you'll have to look him up).

One point was that aggregation and composition relationships worked a bit differently depending on how you created them. This appeared to be a throwback to the UML 1.x days of EA. [I do not know if or to what extent this has been addressed. It might not be your problem here. So read on...]

Meanwhile, I have not done this for a while so I might not remember, try setting the Containment property of each end of the aggregation. You'll find this on the Target - and Source, but this is less likely to matter - Role tab of the Aggregation Properties dialog. [You can also set these through the API, and (I think) a script.]

If that does not work right away, grab a piece of your own source code - something you did not build with EA - and reverse engineer it into an EA project. Take a look at what properties EA sets, and to which values.

Any luck?

HTH, David
No, you can't have it!

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Re: Aggregation Modelling
« Reply #2 on: March 18, 2008, 02:39:44 pm »
Cosmo

You might also look at the navigation direction on the association.  Reversing what you see might help.
Verbal Use Cases aren't worth the paper they are written upon.

Cosmo Nova

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Aggregation Modelling
« Reply #3 on: March 18, 2008, 03:06:32 pm »
Quote
Hey Cosmo,

There was some very good information on EA's implementation of these relationships quite a while back. The threads in question were started - I think - by Paolo Cantoni (in one of his incarnations, you'll have to look him up).

One point was that aggregation and composition relationships worked a bit differently depending on how you created them. This appeared to be a throwback to the UML 1.x days of EA. [I do not know if or to what extent this has been addressed. It might not be your problem here. So read on...]

Meanwhile, I have not done this for a while so I might not remember, try setting the Containment property of each end of the aggregation. You'll find this on the Target - and Source, but this is less likely to matter - Role tab of the Aggregation Properties dialog. [You can also set these through the API, and (I think) a script.]

If that does not work right away, grab a piece of your own source code - something you did not build with EA - and reverse engineer it into an EA project. Take a look at what properties EA sets, and to which values.

Any luck?

HTH, David


thx ur reply

I found this thread, but is it what u were trying to quot??
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1203597016/8#8

for the Containment property, what exactly it represents in a class modelling?  :-/

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Aggregation Modelling
« Reply #4 on: March 18, 2008, 10:02:01 pm »
Cosmo,

That's who I was referring to, but not the particular post.

Try Jim's idea first; it's quick and might do the trick.

If not, just play with containment a bit. If it does not solve your problem then you can leave the definition until later.

If you're still having problems, try importing some code that already does what you want, as I suggested above. Examine how EA models the result, and then try creating a model that is similar. Generate the code and see if that's what you wanted.

David
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Aggregation Modelling
« Reply #5 on: March 19, 2008, 08:27:39 am »
EA doesn't generate anything different for compositions or aggregations.  The pointer is because of the containment specified.

The reverse engineering sounds odd, but I don't really have enough information to know what you're talking about.