Sparx Systems Forum
Enterprise Architect => General Board => Topic started 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
-
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
-
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
-
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:
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
-
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):
- 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:
(http://www88.zippyshare.com/scaled/QmcjBygU/file.html) (http://www88.zippyshare.com/v/QmcjBygU/file.html)
-
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.
-
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