Here are their lecture slides concerning association classes:
Sometimes associations have attributes or behavior that does not belong solely to the class at either end. We can model this using an association class. Assume the following diagram models the allocation of students to modules.
The attribute
finalMark
does not ‘fit’ into either ‘end’ of the association. In addition, it will be necessary to record more than one mark for each student (for each module) and vice versa. Thus, the attributefinalMark
is an attribute of the association betweenStudent
andModule
.The association class adds an extra constraint in that there can only be one instance of the association class between any two participating objects. Therefore, if we allowed
students
to re-sit modules but we still needed to retain thefinalMark
’s of previousenrolment
s, we could not use an association class and would need to ‘add’ a class, Enrolment, and two more associations.Also a
Customer
andPerformance
example. It needs to be a full class as customer can have many bookings:
I'm really struggling to agree with changing dotted notation into the full class. I have looked all over the internet about this and cannot not find anything that uses this approach. I have found the article in which my lecturer got their information from (here) but even the comment on that articles challenges its correctness.
It's really giving me a headache when attempting their assignment they have set so I would like some clarity on the issue.
The constraint they are refering is not existant, for association classes, even when isUnique is set to true. For usual associations, you need to set isUnique to false, to allow this.
A reason why you have found that much information about such a transforming is that many people don't use association classes and instead define immediately with such a "full" class to realize the association. Besides of the fact that the two classes have no direct association, there is technically no real difference between these two concepts. This means in a realization you cannot distinguish in general if the class that realizes the association was defined as an association class or just as a class. Because an association class is also a "full" class (if you want to call it like that), because it is related to the term class by a generalization relation, such as to an association. In consequece it inherits the properties of both (huh, meta-model). To overcome the missing direct association and the not existing constraint, they presented one possible solution. But before discussing them, we can ask if we realy need those both properties? So we need to have the relation several times logically, as defined in the problem: yes. Do we need an direct association between the two instances? Hmm... here, not really. In some cases there might some reasons for this, e.g., when a high level architecture is defined and you are only allowed to refine and complete it, but cannot remove an association, which was defined on a higher level, another reason could be some tool issues or when you want to process the model automatically, or you depending on used database engines, the resolution of associated objects might be faster. But basically you have the connection between the instances without the association.
Another solution would be having the association class and having a further class that contains the information that can be added over time and still contributes to this association. So the class that adds the information can only be linked to one instance of the association class, and the association class can link to arbitrary (or whatever the rules are) instances.
Using qualifiers is, theoretically, also a possibility but I would recommend not to use it for this case, because its intension is somewhat different.
But as always, each approach has some benefits and drawbacks. And for an exam it is mostly better to conform with the teachers, as long as they are not wrong :-)