Book a Demo

Author Topic: the relation between different classes  (Read 15699 times)

SusanneSH

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
the relation between different classes
« on: August 27, 2009, 01:50:23 am »
hello, I met a problem on the relation between different classes.

As I knew, if class A has an attribute B1 which is an intance of classe, we have 2 ways to express. We write it in the list of attribute, or we draw a line between these 2 class. But these 2 ways cann't  exist in the same time.

And I creat an model by a line between these 2 classe, and then generate the code. But after I do the " synchronize the code" for class A, the B1 display as a member of attributes. And these 2 things existe the same time now.

If anybody know how to avoid it ? THX very much!!

lubos

  • EA User
  • **
  • Posts: 101
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: the relation between different classes
« Reply #1 on: October 08, 2009, 07:02:09 pm »
moreover both these attributes could be different types.
Yes, this is quite confusing.

BTW:
I have also the problem with the API, where there is not a simple way how to get all attributes of some class, you have to chesk attributes and associations together.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: the relation between different classes
« Reply #2 on: October 08, 2009, 07:17:50 pm »
Quote
[size=18]...[/size]
As I knew, if class A has an attribute B1 which is an instance of class, we have 2 ways to express. We write it in the list of attribute, or we draw a line between these 2 class. But these 2 ways can't  exist in the same time.
[size=18]...[/size]
Hi Suzanne,

it actually depends on exactly what you are doing.  UML says that an named AssociationEnd IS an Attribute.  Consequently, you have both renderings of the same thing (as an attribute within the class and a destination named association) on the diagram at the same time.

Unfortunately EA doesn't enforce this duality.  It sees them as two separate features, not two renderings of the same feature.

There was some progress toward resolving this, but I believe it went "into limbo".

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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: the relation between different classes
« Reply #3 on: October 08, 2009, 07:18:37 pm »
There are indeed two ways of modelling a static relation between two classes, but they can be used together as well.
You can link an attribute to an association indicating that they both mean the same thing.
That might (I'm not sure) help you with the code generation issue.

In most of the cases it will be a matter of creating your own convention on how you model these types of relations.
For myself I usually only use associations (lines as Susanne calls it ;)) except for relations to datatypes. For those I use the attribute type.

So If you work in a consistent manner then you shouldn't have problems getting the information from the API.

Geert

son-of-sargasso

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: the relation between different classes
« Reply #4 on: October 09, 2009, 11:45:17 am »
Quote
You can link an attribute to an association ...

How?

bruce

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: the relation between different classes
« Reply #5 on: October 09, 2009, 12:03:50 pm »
Quote
Quote
You can link an attribute to an association ...

How?

bruce
Geert may have been referring to the "Link to Element Feature" command - right-click the association very close to its end...
« Last Edit: October 09, 2009, 12:04:25 pm by KP »
The Sparx Team
[email protected]

son-of-sargasso

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: the relation between different classes
« Reply #6 on: October 09, 2009, 12:45:01 pm »
Ah, OK.  "You can link an association end to an attribute" then.


I was just interested in seeing what connotations and effects of doing it the other (Geerts) way would result.  

BTW I do like the "Link to Element Feature" feature.  Is there a succinct explanation of the ramifications of doing this, in terms of diagrams code generation and reverse engineering?  (Yes, I know I'm being lazy. ::) )

bruce

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: the relation between different classes
« Reply #7 on: October 09, 2009, 01:14:42 pm »
I can be very succinct.

They aren't used in code engineering.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: the relation between different classes
« Reply #8 on: October 09, 2009, 06:08:25 pm »
Yeah, well "Link attribute to association" or link "Association(End) to attribute", I don't really see the difference
Anyway, the "Link to element feature" was what I was referring to.

Geert

son-of-sargasso

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: the relation between different classes
« Reply #9 on: October 10, 2009, 11:44:08 am »
Geert,
I wasn't having a go,  I was just adopting my "Graduate of the Paolo School of Pedantry" role and ...  ;)

It appears from some playing around and from Simon's comment above that the "Link to Element Feature" has visual functionality only.  It doesn't have any semantic or code generation effect.

Maybe it could have some semantic effects like setting the role, BUT although its acting visually at the correct association end it would be acting on the wrong association end re roles.  So if that were done we'd end up ANOTHER aggregation end fiasco!

Maybe it could be used to overcome the code generation issue.   I have not considered much about this.

I've really got to go and spray those trees!!  

bruce