Reputation: 351
i am currently trying to design a uml class diagramm for a simple application i'm developing.
The Problem: I have a class, that is a subclass and another subclass of the same superclass. The first one, lets call it subclass1
consists of various elements of the superclass, that is itself and the other subclass2
.
Now i'm not sure how to model this correctly in UML. The following two pictures show the two possibilities i've come up with. Both don't seem correct tbh.
Option 1: subclass1
is an aggregation of it's superclass.
Option 2: subclass2
contains a list of superclass elements
My Question: Is one of these correct and if not, how would i model it correctly?
Upvotes: 1
Views: 181
Reputation: 36295
Basically both diagrams are the same. You are using a shared aggregation in the first where you intend to express multiplicity. This is not correct. Shared aggregation has an open semantic to be defined in the context of a domain.
The picture above would be the preferred way. It uses an association with multiplicity and a role name. This is semantically identical to your second picture.
N.B. I used upper case for the class names as this is a common convention.
Upvotes: 1