list of dots University of Ottawa logo / Université d'Ottawa

User Manual    [Previous]   [Next]   

Independently Defined Associations

An association can be defined separately from any class. Contrast this with the Umple code showing the same model with inline associations.

Specifying an association independently of the two associated classes, as in the example below, can sometimes make code clearer. Specifying the association inline in one of the two classes can be clearer in other cases, particularly when it is defined in the more important class. But the decision regarding which alternative to use is left to the designer.


class Group { }
class Item {}
class Description {}

association {
  * Group -- * Item;

association {
  1 Group -> 0..1 Description;  

Load the above code into UmpleOnline



// Associations can be declared outside the body of classes.
// See user manual page IndependentlyDefinedAssociations
associationDefinition : association [name]? { ([[comment]]
    | [[reqImplementation]]
    | [[mixsetDefinition]]
    | [[association]])* }

association : [=modifier:immutable]? [[associationEnd]] [=arrow:--
    |-<@>] [[associationEnd]] ;

associationEnd : [[multiplicity]] [type] [~roleName]? [[isSorted]]?

association : association [associationNum];