UML Association Class - Refinement

I am reading "UML distilled" by Martin Fowler, and while reading about association classes, I got this quote:

What benefit do you gain with the association class to offset the extra notation you have to
remember? The association class adds an extra constraint, in that there can be only one instance of
the association class between any two participating objects.

      

Then an example came up, but I want to make sure I am correct if for example I got:

 ---------            ---------
|         |*        *|         |
| CLASS A |----------| CLASS B |
|         |     |    |         |
 ---------      |     ---------
                |
          ______|______
         |             |
         |             |
         |  CLASS C    |
         |             |
         |_____________|

      

then for each distinct pair (instance A, instance B) there is only one instance of class C.

So if I took A1, A2, B1, B2 instances, then for (A1, B1) (A1, B2) (A2, B1) (A2, B2) I would get 4 instances of C, nothing more?

+3


source to share


4 answers


This would be correct, with no intention of mixing up the concepts here, but this is similar to tables in a database where:

A 1-* C
B 1-* C

      



Where C can be seen as the result of a breakdown in the many-to-many relationship between A and B.

For each row on B there can only be 1 and only 1 Row C, and for that particular row (on C) there can only be an i associated with 1 row on A. Hence, for each pair of unique rows on A and B, there can only be one line per C or none, as * indicates 0 or more.

-1


source


Your reasoning is correct: if an association class does not have one or both of the association contours annotated with {nonunique}

, then this implies the restriction that there can be only one relationship between the same objects (as Martin Fowler explained).

Note, however, that a variant of non-single association ends was only added in UML 2 (2005), and Martin Fowler's book (from 2003) is for UML 1.x.



Some examples might help. For example, an association LandPurchase

between Person

and PieceOfLand

can be modeld as a UML association class (with a unique default association), since there can only be one purchase relationship between a person and a piece of land. The relationship ProductPurchase

between Person

and Product

can only be modular as an association class if the end of the association is Product

annotated on the side as {nonunique}

, since there can be more than one purchase reference for the same product (as a type) between the same person. For example, I can buy several Tesla Model S models (if I had the money).

Likewise, in the case Appointment

between Person

and Doctor

, since the same person may have more than one appointment with the same doctor, the end of the association on the side Doctor

should be annotated as {nonunique}

.

0


source


From the UML 2.5 spec:

Note that when one or more ends of the AssociationClass have isUnique = false, it is possible to have multiple instances linking the same set of final class instances.

Mr. Fowler may have misunderstood the facts. There is no additional restriction, just the ability to store additional property values.

When isUnique = false, additional properties allow simulating multiple visits to the same doctor on different dates, or, for example, multiple purchases of the same product on different dates.

0


source


Association in UML is represented (has) logical meaning (UML is not a tool for database modeling!). An association describes a possible logical fact. For example. Two people A and B can be married, we can draw this as an association, it represents the meaning as "we know there is a logical connection between person A and person B". If we know what it is, we endow the class association [marriage certificate] as a materialized fact.

0


source







All Articles