Qualified Associations

Qualified Associations

A qualified association is the UML equivalent of a programming concept variously known as associative arrays, maps, and dictionaries.

Figure 6-13 shows a way of representing the association between the Order and Order Line classes that uses a qualifier. The qualifier says that in connection with an Order, there may be one Order Line for each instance of Product.

Figure 6-13. Qualified Association

Conceptually, this example indicates that you cannot have two Order Lines within an Order for the same Product. From a specification perspective, this qualified association would imply an interface along the lines of

    class Order {
       public OrderLine getLineItem
           (Product aProduct);
       public void addLineItem
           (Number amount, Product forProduct);


Thus, all access to a given Line Item requires a Product as an argument. A multiplicity of 1 would indicate that there must be a Line Item for every Product; * would indicate that you can have multiple Order Lines per Product but that access to the Line Items is still indexed by Product.

From an implementation perspective, this suggests the use of an associative array or similar data structure to hold the order lines.

     Class Order {
          private Map _lineItems;


In conceptual modeling, I use the qualifier construct only to show constraints along the lines of "single Order Line per Product on Order." In specification models, I use it to show a keyed lookup interface. I'm quite happy to use both this and an unqualified association at the same time if that is a suitable interface.

I use qualifiers within implementation models to show uses of a map, dictionary, associative array, or similar data structure.