Author Topic: How to show association ends as attributes?  (Read 5801 times)

Stanislaw Tristan

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
How to show association ends as attributes?
« on: July 10, 2008, 08:52:38 pm »
2 classes has many-to-many association. Both ends are navigatable (so in codegeneration this creates a collection attribute for each class). By default EA does not show this collection attributes in the classes. Is there a way to show them automatically?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to show association ends as attributes?
« Reply #1 on: July 10, 2008, 09:23:30 pm »
Take a look at Set Collection Classes in EA help. This does not show up in the index (as of build 831) so look in the contents under Code Engineering | Code Engineering Settings | Source Code Engineering.

You can also set collection classes for individual attributes using the Details tab of the Attribute Properties dialog. You should (probably) save newly-created attributes (from the General tab) before using this tab.
No, you can't have it!

Stanislaw Tristan

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: How to show association ends as attributes?
« Reply #2 on: July 10, 2008, 11:05:04 pm »
Thanks, but after reading I don't solve my task.
I want:
1. Place 1st class (Person)
2. Place 2nd class (Task)
3. Place an association between them
4. In the association properties define multiplicity, navigatability and others
5. After pressing OK I want EA automatically add attribute Tasks in the Peson class and Persons in the Task class

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to show association ends as attributes?
« Reply #3 on: July 11, 2008, 01:34:50 am »
OK,

Basically you want EA to automatically add appropriate attributes (of the correct type etc.) to the classes, based on the roles the connector ends represent.

AFAIK this won't happen automatically in EA, at least not in real time on your diagram. I do believe there is a way to make EA correctly reflect this information in generated code, and possibly in transformations, but I simply don't remember it now.

This - or something very similar - was addressed in the forum some time ago (perhaps before the beginning of this calendar year). I believe the poster was someone from Sparx (but I am not sure). The post involved did go into detail on what EA would and would not do, and presented a step-by-step procedure for getting predictable results. Unfortunately it has been some time and I don't remember enough of the wording to suggest keywords for your search.

David
No, you can't have it!

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: How to show association ends as attributes?
« Reply #4 on: July 11, 2008, 03:32:14 am »
What do you need the attributes for anyway? Code is being generated like it should, as you say.

You may well have a reason to want attributes along with your association ends, but at the moment I can't think of any. What information do you want the attributes to carry which can't be modelled on the association ends? Is it because of the drop down list you get for run states on an instance (which only shows the attributes and not the association ends)?

Stanislaw Tristan

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: How to show association ends as attributes?
« Reply #5 on: July 11, 2008, 03:37:09 am »
This I need for visualization clearness - I want to see any member that will in my future generated class in that class in the model

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: How to show association ends as attributes?
« Reply #6 on: July 11, 2008, 06:06:34 am »
Quote
This I need for visualization clearness

But isn't it clear (proper understanding of UML concepts provided) that an association with a navigable end in the target determines a member in the source? So why have it redundantly modelled as an attribute? Visually its clear enough I think. You have your classes in a diagram with their elementary attributes and associaions to other classes. So which information is missing? Or which information fails to be clearly visble?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8064
  • Karma: +118/-20
    • View Profile
Re: How to show association ends as attributes?
« Reply #7 on: July 11, 2008, 08:34:22 am »
There isn't any option to automatically render associations as attributes.  If you generate code from your model then reverse engineer you will get the attribute.

Stanislaw Tristan

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: How to show association ends as attributes?
« Reply #8 on: July 11, 2008, 09:43:54 am »
Thanks all!
May be I make this myself via automation interface.

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: How to show association ends as attributes?
« Reply #9 on: July 13, 2008, 03:21:25 am »
Hi' Frank

One reason, when the related classes are not shown in the diagram but you still want a hint that the association is there... this can help when you have a class in more than one diagram.

Agree completely silly to show as both an attribute and association on the same diagram.

The class diagram in Visual Studio, of course, enables you to choose how you show them ( as a class attribute or as an association )... and slightly more interestingly for Properties too.

Kevin

Stanislaw Tristan

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: How to show association ends as attributes?
« Reply #10 on: July 13, 2008, 04:29:36 am »

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: How to show association ends as attributes?
« Reply #11 on: July 13, 2008, 05:42:40 am »
Kevin,

I see your point. It's not always nice to have all associated clases on a diagram. But I wouldn't like to have redundant model data either, and I'm sure that more often than once I would delete the association but forget to delete the attribute, or vice versa.

Maybe the best solution would be if EA supported a "show additional roles" option for diagrams, priting all named association ends pointing to classes not on the diagram, e.g. in the attributes compartment, like the "show additional parents" option printing missing base classes on top of the class shape.

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: How to show association ends as attributes?
« Reply #12 on: July 24, 2008, 08:54:35 pm »
Frank

Thanks for your reply, I'm with you on most of what you suggest.

I'm a little confussed regarding redundant model data tho... If I deleted the association then surely EA wouldn't have an 'associated' attribute to worry about; perhaps EA should provide a warning message box if you deleted the 'attribute' before it deleted the association.  Having to whizz about deleting the association and untold occurances of the hint, that would really upset my superiors.

Really I think the 'association hint attribute' should visually appear different from a class property (UML2 speak for an attribute)... something simple like a pastel font colour.  

In my dreams, these attributes would vanish as I drop the associated class onto the diagram... and remarkably re-appear if I delete it from the diagram at a later point;  or in some other fashion change the name, navigablity, or multiplicity of the association end....  [smiley=thumbsup.gif] endless hours of team games to be had with a feature like that. [smiley=grin.gif]

Kevin [smiley=2vrolijk_08.gif]