I am creating UML diagrams for others' code, and I encountered something peculiar- a child class has a parent class as one of its member variables, seemingly both a "has a" and an "is a" relationship. Apparently, this is intentional, but even after looking through UML guides, I'm still lost on how to even represent this. Do I only show Inheritance, the stronger relationship? Do I overlay the arrows, creating a solid white arrowhead with a line through it?
With replaced class names in Java:
public abstract class A {
}
public abstract class B extends A {
protected A a;
}
How would I represent this?
You have two different relations, so you simply just show them both
From the code alone there is no evidence that the Association
between B and A is also a Composition
, so I kept it to a plain association.
There are a few questions here that explain the differences between associations and compositions quite nicely e.g.
What is the difference between association, aggregation and composition?
The fact that both classnames are in Italics indicates the fact that they are both declared Abstract