Reflexive Associations
Associations
noreferences
@@tooltip A reflexive association is an association from a class to itself


@@description

<p> A reflexive association is an association from a class to itself. 
There are two main types: Symmetric and Asymmetric.</p>

<p><b>Asymmetric Reflexive Associations:</b> The ends of the association 
are semantically different from each other, even though the associated 
class is the same. Examples include parent-child, supervisor-subordinate and predecessor-successor.</p>

<p>The 
first and second examples below show courses having prerequisites that are 
other courses. It is necessary to specify a <a href="RoleNames.html">role 
name</a> at one or both ends of the association to distinguish the ends. 
Also it is necessary to ensure that the lower bound is always zero on both 
ends. The reason for this is that otherwise an illogical situation would 
arise: For example, if you said that each course must have one or more 
pre-requisites, then what about the very first courses in the hierarchy? 
The compiler will <a href="E009ReflexiveLowerBound.html">report an error 
if the lower bound on a multiplicity is one or higher.</a></p>

<p>The following is how an asymmetric reflexive association appears in UML, as generated by UmpleOnline. The corresponding Umple code is in the first example below.</p>

<img src="examples/PrerequisiteSuccessorReflexiveAssoc.png" alt="UML Class course with asymmetric reflexive many-many association with role names prerequisites and successors" />

&nbsp;<br/>


<p><b>Symmetric Reflexive Associations:</b> There is no logical difference 
in the semantics of each association end. The fourth example shows one of 
these: A set of courses that are mutually exclusive with each other 
essentially make up a set. If course A is mutually exclusive with B, then 
course B is mutually exclusive with A. In other words, students who have 
taken one course cannot take another in the set. Umple uses the keyword 
'self' to identify this case. Note that at the current time the asociaton 
itself does not appear in UmpleOnline; this will be fixed.</p>

&nbsp;<br/>

@@syntax

[[symmetricReflexiveAssociation]] 

@@example @@caption Asymmetric association with role names on both ends @@endcaption
@@source manualexamples/ReflexiveAssociations1.ump
@@endexample

@@example @@caption Asymmetric association with role names on one end @@endcaption
@@source manualexamples/ReflexiveAssociations2.ump
@@endexample

@@example @@caption Asymmetric association with role names on the other end @@endcaption
@@source manualexamples/ReflexiveAssociations3.ump
@@endexample

@@example @@caption Symmetric association @@endcaption
@@source manualexamples/ReflexiveAssociations4.ump
@@endexample
