简体   繁体   中英

Representing An Association and Inheritence in UML

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?

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.

在此输入图像描述

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.

组成:

协会

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM