Are qualified associations necessary?

When I'm creating domain models, the ability to place properties on a relationship is proving very useful.

For example, at the moment I'm remodelling our designer definition format (we generate it from a domain model) and have a relationship between Connector and Decorator and Shape and Decorator. Decorators have a position, which is modelled as an enumeration (inner-top-right, etc.), but the values of the enumeration are different depending on whether the decorator is on a Shape or on a Connector (inner-top-right is not a meaningful position for a connector). Without properties on relationships, we'd have to subclass Decorator to ShapeDecorator and ConnectorDecorator, and all we'd be adding was a differently typed Position property in each case. With properties on relationships, we can just attach a differently typed Position property to the relationships from Shape to Decoarator and from Connector to Decorator, respectively - no subclassing required.

UML has associations which are like our relationships. You can attach properties (attributes) to associations via their association classes. UML also has qualified associations, where you can index links of the associations by a property - e.g. an integer or a position. But it seems to me that one could achieve the effect of qualified associations by adding attributes to association classes, as we add properties to relationships. So, in my mind, if you've got association classes, qualified associations are redundant.

Am I missing something?

Comments (4)

  1. Jim says:

    What are you saying? There’s more than UML than is strictly necessary? Surely not!

  2. Anders Ivner says:

    Yes. If the association has a 0..1 or 1 multiplicity, the qualifier acts as a uniqueness constraint (i.e. for each Connector there can only be one Decorator for a given position value).

  3. Me says:

    Are you suggesting that the constraints on valid configurations of objects/links/link-properties are identical with (a) vanilla properties on relationships and (b) qualified associations?

  4. Anders, I think you’ve identifed exactly what qualifiers add, which is the uniqueness constraint, in the case of multiplicity max = 1.

Skip to main content