Representing An Association and Inheritence in UML

Viewed 44

If I had a class definition that looked like this:

class A extends class B {
private B b
}

How could I represent this relationship in UML? Also is this a bad design and why?

2 Answers

The extends keyword in Java stands for a generalization, shown as a hollow triangle in UML.

The association is shown as a solid line. The role name b is attached towards the B class with a - prefix for a private one. And the large dot tells that it's an owned property of A.

There's basically nothing wrong with that.

enter image description here

Before deciding if this is a bad design or not, you should give us your context.

For your first question: you can do something like this.

Composition:

Association

Related