Previous Table of Contents Next


6.5 Reference Representations

   [21] ReferenceInstance := 22:ContainedReference | 23:NonContReference

   [22] ContainedReference := ( <ReferenceName> (’:’ | ‘=’) )? (6:ClassInstance | 13:ClassInstanceRef)

   [23] NonContReference := <ReferenceName> (’:’ | ‘=’) 13:ClassInstanceRef

   References are a means for classes to be aware of class instances that play a part in an association, by providing a view into the association as it pertains to the observing instance. For this reason, the representation within a class instance of a reference depends in part on the nature of the association to which it refers. An association is involved in a containment relationship if one of the participating instances is wholly contained within the other. That is, the contained instance does not exist outside the scope of the other instance.

   Much like that of an attribute, the representation of a reference begins with the name of the reference followed by a colon or an equals sign. If the instance to which the reference refers is the contained instance in a containment relationship, then this may be followed either by a full representation of the instance (see 6.3, “Class Representations), or by a reference to the instance. In the latter case the full representation of the contained instance must appear as a top level definition in the content of the current package. Figure 6-9 shows the Family class with references, ‘naturalChild’ and ‘adoptedChild,’ to two containment associations between the Family and Person classes.

   FamilyPackage “id-001? { Family “The Smiths? {

   Attribute representationsReference representations

   naturalChild: Person “Harry Smith? {

   Attribute and reference representations

   }naturalChild: Person “Joan Smith? {

   Attribute and reference representations

   }adoptedChild: Person “Dylan Smith? {

   Attribute and reference representations

   } } }

   Figure 6-9 An example representation for a reference to a containment association

   If there is only one association through which a contained object may be referred, then the shorthand of a nameless reference is available, in which the name of the reference (and the trailing colon) may be omitted.

   August 2004 Human-Usable Textual Notation, v1.0

   Alternatively, if the association that is referred to is not a containment relationship, then the subsequent depiction must be in the form of an instance reference. An example of this case is given in Figure 6-10, where familyFriends is a reference to a non-containment association ‘familyFriendship.’

   FamilyPackage “id-001? { Family “The McDonalds? {

   Attribute representations

   familyFriends: Family “The Smiths? } Family “The Smiths? {

   Attribute representations

   familyFriends: Family “The McDonalds? } }

   Figure 6-10 An example of the representation of references to a non-containment association

   If the class referred to by a non-containment association (and all its subclasses) uses a common identification mechanism (either a single identifying attribute or the arbitrary unique identifier), then the type name of the referred class may be omitted, as a typeless reference.

   It should be noted that an association link need only be represented once throughout the document. For example, in the case of an association between two classes where both classes have references to the association, a link need only be shown in one of the three possible places it may appear; in one of the two references, or in the representation of the association. The link may be shown more than once, so long as the different representations are consistent.