Author Topic: 3-way Association Class  (Read 6592 times)

mylesr

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
  • Howdy!!
    • View Profile
3-way Association Class
« on: December 16, 2005, 08:10:32 am »
In a class diagram, I can add an association class, complete with attributes and operations, to handle the details of a many-to-many relationship between two classes.  Now I have a need to create a 3-way association class, i.e.  I have a relationship based on combinations of three classes.  I tried the "n-ary association", but I need a class to hold the additional attributes and operations that relate directly to each specific 3-way combination.  How can I accomplish this in EA?  

Thanks in advance!  

Myles Pippenhagen

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: 3-way Association Class
« Reply #1 on: December 18, 2005, 04:06:11 pm »
Myles,

No UML spec I've ever seen has shown this, so I can only guess, but I would draw it as follows...

Your n-way association will have 1 class at one end and n-1 classes at the other, representing a grouping of n-1 associations between the 1 class and the n-1 others. I would attach the association class to the association connector between the 1 class and the association diamond.

Neil
The Sparx Team
[email protected]

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: 3-way Association Class
« Reply #2 on: December 18, 2005, 04:12:22 pm »
Quote
In a class diagram, I can add an association class, complete with attributes and operations, to handle the details of a many-to-many relationship between two classes.  Now I have a need to create a 3-way association class, i.e.  I have a relationship based on combinations of three classes.  I tried the "n-ary association", but I need a class to hold the additional attributes and operations that relate directly to each specific 3-way combination.  How can I accomplish this in EA?  

Thanks in advance!  

Myles Pippenhagen
Myles,

look up "Lozenge" in the forum search.  You find a lot of (my) thoughts on this topic.  If you agree with the ideas - petition Sparx to implement them...

However, if you intend to generate code directly from an n-Ary Association good luck.  I'm not aware of any tool that allows you to do this... If anyone knows of one, let me know as I'm interested (for my UMLPlus XML interface)

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

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: 3-way Association Class
« Reply #3 on: December 18, 2005, 04:26:41 pm »
Quote
Myles,

look up "Lozenge" in the forum search.  You find a lot of (my) thoughts on this topic.  If you agree with the ideas - petition Sparx to implement them...

However, if you intend to generate code directly from an n-Ary Association good luck.  I'm not aware of any tool that allows you to do this... If anyone knows of one, let me know as I'm interested (for my UMLPlus XML interface)

Paolo


Have you considered a shapescript to draw a lozenge for a stereotyped class? Something like this to get you started:

Code: [Select]

shape main
{
   startpath();
   moveto(0,50);
   lineto(50,0);
   lineto(100,50);
   lineto(50,100);
   lineto(0,50);
   endpath();
   fillandstrokepath();
}


Then you can modify your code-gen template as required for the given stereotype and Bob's your Uncle...

Neil
The Sparx Team
[email protected]

rty

  • EA User
  • **
  • Posts: 28
  • Karma: +2/-1
    • View Profile
Re: 3-way Association Class
« Reply #4 on: February 10, 2016, 10:31:13 pm »
Just for the records (and others who try to find out how to create an association class for n-ary associations (lozenge notation): it's valid UML, according to UML 2.5 (09-2013). Check the Examples subsection of section 11.5 Associations, figure 11.36:

Aaaaand it's possible to create an identical visual experience (abusing improper connections):
  • Create your classes and the lozenge notation of the n-ary association.
  • Create the association class by associating it to any association.
  • Detach the association class from that association (Acvanced > Un-link Class and Association).
  • Connect the lozenge and the association class using the Dependency connector.
  • Remove the dependency's arrow head (Properties > Direction := Unspecified).
There you go:
« Last Edit: February 10, 2016, 10:34:50 pm by rty »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: 3-way Association Class
« Reply #5 on: February 11, 2016, 12:54:23 am »
You should create an association between the two main classes and use context/Advanced/Association Class on the association class to make the right link.

q.
« Last Edit: February 11, 2016, 12:01:11 pm by qwerty »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: 3-way Association Class
« Reply #6 on: February 11, 2016, 10:57:00 am »
Please see my comments in: http://sparxsystems.com/forums/smf/index.php/topic,14823.msg221021.html#msg221021

The solution is, unfortunately incorrect as a model.

If viewers are trying to create models instead of pictures, please don't use this mechanism.  See the referenced post - for the reasons why.

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