References

A reference describes an assignment of one or more other specialist objects. In the user interface, a reference is not entered as a value, but is selected from a set of existing other objects.

Use of references

When modeling, you often have the choice of representing a property as a reference to another specialist object or as a primitive text attribute. When describing a robot, an important property is certainly its manufacturer. The manufacturer could be modeled as a simple text attribute just like the name of the robot. Another alternative would be to introduce a separate class Manufacturer whose instances describe robot manufacturers. The Manufacturer property of a robot could then be implemented as a reference to an instance of the Manufacturer class.

Both modeling variants have advantages and disadvantages. In the case of the text attribute, the user of the application is completely free to decide what to enter in the "Manufacturer" field of a robot. They can use new manufacturers at any time without having to create new instances for a new manufacturer in the system beforehand. However, they do not receive any help when filling in the "Manufacturer" field. This usually leads to several spellings being established for one and the same manufacturer. If you then want to make evaluations of this property (e.g. how many robots from which manufacturers are in use), inconsistent entries, which are possible with a text attribute, lead to inaccurate or incorrect evaluations. In the modeling variant with a manufacturer reference, only those manufacturers that are also administered in the system can be entered or selected in an input field for "Manufacturer". Data consistency is generally better here than with the variant with the text field.

Creating references

A reference is represented in the class diagram by an arrow starting from the class that has the reference property. The arrow ends at the target type of the reference.

References can be created in the diagram by selecting the source class and dragging the simple arrow symbol onto the value class of the reference in the toolbox that then appears.

In the dialog that then opens, the value type of the reference (Manufacturer) is already preselected. All that remains to be done is to select a technical name for the reference. The same naming convention should be followed as for attributes (small initial letter, no spaces or special characters).

Display in the diagram

After completing the creation, the reference is displayed in the diagram as an arrow. The arrow starts at the class whose property the reference represents and ends at the target type of the reference. The diagram below can be read as follows: "A Robot system has one or no (0..1) Manufacturer of the type Manufacturer".

The name on the arrow is the name of the property. In the example above, it is noticeable that this name (Manufacturer) is the same as the name of the target type of the reference, although manufacturer was entered with a lowercase initial letter in the input field for the reference name. This can be explained by the fact that the diagram also uses the display names for references by default and a display name "Manufacturer" with a capital letter was automatically derived from the technical name of the reference "manufacturer" when the reference was created.