Book a Demo

Author Topic: Add class attribute with an Association?  (Read 4469 times)

reddog

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Add class attribute with an Association?
« on: December 03, 2004, 10:45:12 am »
When I add an association from Class A to Class B I want an attribute to be added to Class A and it to be shown in the diagram, while the attribute should be configurable somewhere.

Eg in C++ I would get:
m_ClassA : ClassA*;
or
m_ClassA : ClassA;
or maybe a configurable STL container.

Together and every UML design package I have tried do this.

I note that if I import existing code then simple Associations do appear.

Hopfully I have missed a setting somewhere, and someone will tell me as so far my one week test drive of EA has been quite good.

Reddog.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Add class attribute with an Association?
« Reply #1 on: December 05, 2004, 02:38:53 pm »
Have a look at "Tools | Options | Generation". There is a checkbox labelled "Do not generate members where association direction is unspecified" which you might need to switch off.
The Sparx Team
[email protected]

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Add class attribute with an Association?
« Reply #2 on: December 05, 2004, 05:13:00 pm »
Open the options dialog (Tools | Options)
Check out:
  • Generation | "Auto generate role names when creating code"
  • Generation | "Do not generate members where association direction is 'Unspecified'" (As KP said)
  • Generation | Attributes/Operations | "Default name for associated attrib"
  • Generation | C++ Specifications | "Default Reference Type"
  • Generation | (C++, Java,VB,C#,Delphi,VB.Net) Specifications | "Collection Classes".  This can be overridden on a class by class basis in the Detail tab of the class properties and clicking the "Collection Classes..." button.  (This should be done for the class that you want a collection of.)


Simon

reddog

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Add class attribute with an Association?
« Reply #3 on: December 06, 2004, 03:56:35 am »
Thanks,

But I still cannot get this to work!

I have looked at all the settings indicated (and "Do not genterate members where association direction is 'Unspecified' is unset), but I still cannot get EA to drop in an attribute (pointer or whatever) into either the source or destination class, after dragging an "Associate" link between the two classes.

I have tried this with PHP and C++ set as the language  in the class->general dialog.

I have tried all the other 'arrows' n the structure (class) toolbar. I have also tried this in a 'virgin' EXExample.eap as well.

Question: does it 'work' for you in a 'virgin' EXExample.eap --- ie does a 'link attribute' appear in the class diagram, as would set/get members if I were to force an attibute to be a 'property' ??

Any other idea?

[...wimpers off, tail between legs, head bowed, stage left...]

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Add class attribute with an Association?
« Reply #4 on: December 06, 2004, 02:40:44 pm »
Sorry, I misunderstood your question.  EA doesn't create an attribute in your class diagram.  If you really want it though you can generate the code and then reverse engineer it.

Simon

reddog

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Add class attribute with an Association?
« Reply #5 on: December 07, 2004, 01:26:40 am »
Thanks for the reply.

At least I know now!

I think this should be a feature of EA - selectable from the project options maybe.

I will post a feature request.

Reddog.