Book a Demo

Author Topic: Code generation for Associations  (Read 5081 times)

dserodio

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Code generation for Associations
« on: March 22, 2005, 06:42:56 am »
Can EA generate methods for associations, or only attributes?
Correctness is clearly the prime quality. If a system does not do what it is supposed to do, then everything else about it matters little. - Bertrand Meyer

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation for Associations
« Reply #1 on: March 22, 2005, 03:52:28 pm »
Play around with the linked attribute templates.  You can generate a method if you want.

It won't synchronise though.

Simon

dserodio

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Code generation for Associations
« Reply #2 on: March 23, 2005, 06:48:53 am »
Thanks for the tip, I created a "LinkedAttribute__Body" template and it works. I will post it to the forum later.

*But* it only works for "plain" associations, not with aggregation nor composition. Why is that? Is there any way around it?

Thanks again.
Correctness is clearly the prime quality. If a system does not do what it is supposed to do, then everything else about it matters little. - Bertrand Meyer

da_Burp

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Code generation for Associations
« Reply #3 on: August 02, 2007, 02:44:50 am »
Quote
*But* it only works for "plain" associations, not with aggregation nor composition. Why is that? Is there any way around it?

It seems this behaviour is still the same in version 6.5.806. Even though I came across this behaviour during transformation and not generation it is identical. So a composition or aggregation won't result in a linked attribute. Is there any specific UML design reason why it is implemented like this?

I have a model here where a composition is bi-directional. But  because the composite side doesn't result in a Linked Attribute it's not really navigable. I've never see it in any model using this bi-directional composition, and I faintly remember reading something it's actually not appropriate, but i'm not sure about that. But I wonder what there would be against this.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Code generation for Associations
« Reply #4 on: August 02, 2007, 02:54:42 am »
What about EA 7.0?
No, you can't have it!

da_Burp

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Code generation for Associations
« Reply #5 on: August 02, 2007, 03:11:04 am »
I could give that a try on another PC later on. If it works I will drive the version manager nuts though, ;D Since we have the policy of sticking to a version for a little longer. This is because each update requires a new roll-out has to be arranged for the whole company. ;)

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation for Associations
« Reply #6 on: August 02, 2007, 05:51:49 pm »
The rules for what constitutes an attribute vary somewhat between associations without any aggregation and those that do.  However, LinkedAttribute templates should still execute for aggregations and compositions.  (They won't generate at the other end)

da_Burp

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Code generation for Associations
« Reply #7 on: August 02, 2007, 09:46:58 pm »
Quote
The rules for what constitutes an attribute vary somewhat between associations without any aggregation and those that do.  However, LinkedAttribute templates should still execute for aggregations and compositions.  (They won't generate at the other end)
And that axectly what i'm running up against now. So the only option is to have bot sides navigable is either make it a bi-directional association again or to add the attribute X manually on class B the PIM in the following situation: [A]<><-X---Y->?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation for Associations
« Reply #8 on: August 03, 2007, 01:27:17 am »
Yes, either of those two options should work.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Code generation for Associations
« Reply #9 on: August 03, 2007, 02:33:37 am »
Perhaps this would be a good thing to add to the properties dialog for connectors. The new tabbed dialogs would seem to support this well.

Just my 0.02 CAD worth...

David
No, you can't have it!