Book a Demo

Author Topic: Association Has-A Question  (Read 5139 times)

bantl

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Association Has-A Question
« on: July 24, 2002, 09:18:32 pm »
I'm new to UML and EA.  When I'm creating two classes I want to show an 'association' (has-a) between them for example:

Car -- (1) ---------- (1) --> Steering Wheel

I'm having trouble determining the proper way to implement the class diagram.

If I add a Steering Wheel attribute to the Car class and an association between the Car and Steering Wheel class I get two references in the Car class when the code is generated.

I believe I'm suppose to have a Steering Wheel attribute in the Car class but then I can't have the association because code generation is improper.

If I get rid of the attribute the code generates properly but its no longer an attribute.

If I get rid of the association the code generates properly but I no longer see the association.

What is the correct way to show this 'has-a' relationship in EA so the diagram is offical UML and the code generates properly.

Thanks to anyone for there help.

Molto Mike

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
    • View Profile
Re: Association Has-A Question
« Reply #1 on: July 25, 2002, 08:40:05 am »
AFAIK, it is UML compliant to show an attribute *either* through an association *or* as an explicitly in the attribute compartment.

Mike

Ilia

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Association Has-A Question
« Reply #2 on: July 25, 2002, 10:46:17 am »
Try to set Steering Wheel Role Name = attribute name.

Duc-bert

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Association Has-A Question
« Reply #3 on: July 25, 2002, 11:52:15 am »
use [strong] aggregation to represent the "has-a".
you can use "target role" with the association so the code gen knows to create only one.
enjoy