I have to create java classes based on this UML diagram
.
The problem is that I don't know what is the relationship inside the red shape.
I did all the other relationships between the A, B, C, D
classes but this one I cannot understand it.
Can anyone give me a hint ?
So far I have :
class A extends B
class D extends C
class C
List<B> bElement;
class D
List<A> aElement;
Thanks.
This means that the lower association inherits from the upper one. Just like the lower classes inherit from the upper ones.
The concept of connector inheritance has only been introduced in a recent UML release (according to @Henriette's answer from 2.0 on). Anyhow, neither the lower association nor its generalization is actually needed since its inherited along with the both generalizations anyway.
Personally I have not found a good use for this concept, but know people that do use it (they work on very high abstraction levels in ontology).
P.S. There's not much to be read about the concept in the specs except for p. 692:
Generalization arrows between association lines are interchanged as UMLEdges with Generalizations as modelElements, and sources and targets that are UMLEdges with Associations (including AssociationClasses shown as lines) as modelElements.
Association inheritance was introduced in UML 2.0 in 2005. Although UML is probably most often used in object-oriented analysis and design, it is aimed at being a general purpose modeling language. As such it includes features like multiple inheritance, attribute specialization/refinement and association inheritance that is not necessarily supported in programming languages. However, in ontology languages like OWL 2 these notions are natural to express.
For some other purposes I have done a write-up w.r.t. association inheritance and equivalent UML representations, which I provide here for in case it is helpful to others.
With regards to associations and attributes the UML specification defines three closely related notions namely association specialization
, subsetting
and redefinition
. Association specialization is applied at the level of the complete association while subsetting and redefinition
are applied at the level of association ends and attributes.
The meaning of association specialization is similar to that of classes. That is, association A2
is a specialization of association A1
in Figure (a). Therefore every link between instances of classes C3
and C4
is necessarily a link between instances of classes C1
and C2
. However, every link between instances of classes C1
and C2
is not necessarily a link between instances of classes C3
and C4
.
Due to C3/C4
specializing C1/C2
in Figure (a), it follows that all associations between C1
and C2
will be inherited by C3
and C4
. Moreover, all inherited associations between C3
and C4
will necessarily be subsets of the associations between C1
and C2
. However,
Figure (a) goes further than that: not only is the association A1
inherited by C3
and C4
, it also introduce a new association A2
. Since A2
is a new association, without the association specialization one will not be able to deduce anything about how A1
relates to A2
. Hence, in Figure (a) the purpose of the association inheritance is to introduce a new association A2
and state how it relates to the existing association A1
.
In Figure (b) it is stated that c4 {subsets c2}
. This means that the collection of instances represented by the association end c4
is a subset of the collection of instances represented by the association end c2
. The same holds for association ends c3
and c1
. Subsetting
is distinguished from association specialization in that subsetting considers set membership only whereas association specialization specializes the characteristics that determine link membership.
Redefinition is used to change the definition of a feature. As an example association end c4
redefines c2
in Figure (c). Redefinition is distinguished from association specialization in that redefinition is defined for an association end rather than for the complete association.
Though the original question pertained to association inheritance used in inheritance hierarchies, it may be enlightening to note that association inheritance can also be used in the absence of inheritance hierarchies. In Figure (d) all the woman a man has been divorced from is a subset of the women he has been married to.
In Figures (a) and (d) the associations are first class citizens of the model. They therefore may be represented by association classes (A1/A2
and MarriedTo/DivorceFrom
) with an inheritance relation between the respective association classes, though making use of association specialization may be more succinct in indicating your intention to specialize associations than specialization between association classes.
In summary: The specialization of an association is equivalent to the subsetting of (one of) its ends and redefinition can be treated as a subconcept of subsetting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With