Book a Demo

Author Topic: Redefining associations  (Read 5786 times)

Torsten Binias

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Redefining associations
« on: May 01, 2008, 12:40:39 am »
Hello,

I want to redefine an association, but EA doesn't let me.
The situation is depicted below.

+---------+        b  +---------+
! Class A !---------->! Class B !
+---------+        1  +---------+
     ^
    / \
    ---
     !
     !
     !  
+---------+        b  +---------+
! Class C !---------->! Class D !
+---------+        1  +---------+
                   {redefines A::b}

In class C I want to redefine the inherited property A::b. But when I choose "Advanced/Specialize Association..." from the context menu EA says "There are no items to show in this view."

I suppose this is a bug. I'm using EA 6.5.801.

Best regards,
Torsten

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Redefining associations
« Reply #1 on: May 01, 2008, 12:48:21 am »
Wouldn't D need to generalize B?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Redefining associations
« Reply #2 on: May 01, 2008, 08:36:46 am »
Frank is correct.  D would need to specialize B for this to be a valid redefinition.  At least as far as EA is concerned, and I'm relatively confident that is right.

Also.  Check that the actual direction of those associations is the same.  (The source elements are A and C, and you don't have one set to a reverse direction.)
« Last Edit: May 01, 2008, 08:39:55 am by simonm »

Torsten Binias

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Redefining associations
« Reply #3 on: May 02, 2008, 10:04:52 pm »
Yes, it works, if D specializes C in EA but that's not what I want. Smiley
I just want to model the following code:

class A {
  B b = null;
}

class C extends A {
  D b=null; // overwrites b inherited from A.
}

Can't I do that with EA?

Best regards,
Torsten
« Last Edit: May 02, 2008, 10:05:45 pm by binias »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Redefining associations
« Reply #4 on: May 06, 2008, 09:23:30 pm »
I think you can't do that because of the rules of object orientation.
The association from A to B is a defining feature of class A. If you create a subclass eg. C this subclass should be able to take the place of A in any circomstances. The fact that the class no longer has an association to B but now has an association to D (which is no B) probably changes this ability.
I think your design would be a violation of the "Open/Closed" principle.

Torsten Binias

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Redefining associations
« Reply #5 on: May 07, 2008, 12:53:39 am »
Yepp, that's right. It just doesn't make sense ro redefine b in such a way.

Thanks,
Torsten