P H
P H

Reputation: 11

UML Diagram When Class has both Is-a and Has-a relationship

I was wondering how we present a class that has both a "has-a" and "is-a" relationship with another class in a UML diagram.

I am wondering if this is correct:

enter image description here

Upvotes: 1

Views: 1144

Answers (2)

Ister
Ister

Reputation: 6318

Simply use two relationships - one showing a generalization and a second showing association/shared aggregation/composite aggregation.

Below is an example with composite aggregation.

Simultaneous generalization and composite aggregation

In case of association the method you suggested is an alternate notation having exactly the same semantics. You only need to use solid line not dashed for generalization as in my example. Dashed line depicts realization and points to an interface or any other specification that is implemented by class on the other end of realization arrow.

Upvotes: 1

qwerty_so
qwerty_so

Reputation: 36313

A realize relation is used to either an <<interface>> or to an abstract class. So you would design it like this:

enter image description here

N.B.: The triangle from the realization must not overlap the class but touch it. Also there's likely a typo: seal instead of sell.

Upvotes: 2

Related Questions