Author Topic: Mutually Exclusive Associations  (Read 10632 times)

NigelSimpson

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Mutually Exclusive Associations
« on: November 30, 2004, 08:48:00 am »
How can I represent mutually exclusive associations in a UML diagram? I used to do this in Entity Modelling with exclusive arcs on the relationships. I want to be able to say that Class A is associated with Class B OR C (but never both).

In simple cases, I can deal with it by subtyping (Class A.1 is associated with Class B, Class A.2 is associated with Class C). However, where there are already subtypes for a different purpose, and I want to indicate that they all can have this exclusive relationship then I find it impossible without getting in to a chaos of sub-subtypes.

In Select Enterprise there was the notion of parallel inheritance where a class could have two or more strands of inheritance but this is still not as elegant as the entity exclusive arcs. How can this be addressed in Enterprise Architect?

thomaskilian

  • Guest
Re: Mutually Exclusive Associations
« Reply #1 on: November 30, 2004, 08:51:09 am »
Attach a constraint? You can find this by right-clicking the association.
« Last Edit: November 30, 2004, 08:52:18 am by thomaskilian »

Gary W.

  • EA User
  • **
  • Posts: 139
  • Karma: +0/-0
    • View Profile
Re: Mutually Exclusive Associations
« Reply #2 on: December 01, 2004, 10:03:46 am »
Nigel,

UML has no notion of 'a set of mutually exclusive static relationships'.    In addition to Thomas' suggestion, you may be also to use OCL to denote this sort of thing.  You may already know about OCL, but if not, just google "Object Constraint Language" and you'll get lots of info.

Hmmm, in writing this post, I can't remember ever having to do this in my previous OO projects.  I wonder if the OO-style analysis and UML notation allows you to avoid this sort of construct???

Anyways, OCL may be the way to go, so you'll have to include the related 'OCL document' along with your class model to make a complete Requirements Analysis deliverable.

gary

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Mutually Exclusive Associations
« Reply #3 on: December 01, 2004, 01:56:11 pm »
In fact, there is a way to unambiguously show this in EA - by using a constraint on the connections.

Suppose a model of ObjectA, ObjectB and ObjectC and two associations ObjectA-ObjectB and ObjectA-ObjectC.
Right click on one of the associations and select "Attach Note or Constraint" from the menu.
At the top of the dialog box, select the Constraint radio button.
In the list of links select both objects and click OK.
You may now enter a constraint that applies to both links.

;)
Bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Gary W.

  • EA User
  • **
  • Posts: 139
  • Karma: +0/-0
    • View Profile
Re: Mutually Exclusive Associations
« Reply #4 on: December 03, 2004, 11:09:15 am »
Sargasso,

Wow, I never knew you could do that!!  Thanks, I think your solution is the way better than mine, and I'll start using this notation..

cheers,
gary

NigelSimpson

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Mutually Exclusive Associations
« Reply #5 on: December 04, 2004, 06:44:42 am »
Thanks to Gary and Thomas for your suggestions, and thanks to Sargasso who gave me just what I wanted - a simple way to show the exclusivity on a diagram and have all links share the constraint without having to replicate it for each association. Great idea!

angel-o-sphere

  • EA User
  • **
  • Posts: 112
  • Karma: +0/-0
    • View Profile
Re: Mutually Exclusive Associations
« Reply #6 on: December 15, 2004, 04:14:46 pm »
A lot of nice suggestions.

One question: would it make sense that B and C have a common base class? Or a common interface?

angel'o'sphere

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Mutually Exclusive Associations
« Reply #7 on: April 10, 2005, 05:17:51 am »
The UML 2 specifications also include (in addition to applying constraints to more  than one element) the notion of GeneralizationSets and Powertypes.

It would be great if EA supported both of these also.

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

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Mutually Exclusive Associations
« Reply #8 on: April 12, 2005, 07:26:27 am »
Constrained associations can get cumbersome if the number of choices is large. I have seen this sort of construct expressed with a parameterized class, the parameter being a base class for the "one of" set of classes.
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.