Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: mylesr on December 16, 2005, 08:10:32 am

Title: 3-way Association Class
Post by: mylesr 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
Title: Re: 3-way Association Class
Post by: KP 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
Title: Re: 3-way Association Class
Post by: Paolo F Cantoni 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
Title: Re: 3-way Association Class
Post by: KP 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
Title: Re: 3-way Association Class
Post by: rty 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:
(http://www87.zippyshare.com/scaled/5YBDhVcv/file.html) (http://www87.zippyshare.com/v/5YBDhVcv/file.html)
Aaaaand it's possible to create an identical visual experience (abusing improper connections):
There you go:
(http://www88.zippyshare.com/scaled/QmcjBygU/file.html) (http://www88.zippyshare.com/v/QmcjBygU/file.html)
Title: Re: 3-way Association Class
Post by: qwerty 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.
Title: Re: 3-way Association Class
Post by: Paolo F Cantoni 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