Warm tip: This article is reproduced from serverfault.com, please click

UML If parent class connect, do children also have to

发布于 2020-11-30 22:21:57

I'm making a class diagram for my project documentation, and have come across this case. There are quite a few connections already in the diagram, and I would like to add on as little as possible. So I thought, if an (abstract) parent class has connections with some other class, it's children usually also keep up the same connection. Is it also the case with UML diagrams, or do I have to connect every chilren to the other class too?

Example image, of what I'm thinking would be possible: enter image description here

Questioner
Barnabas Valent
Viewed
2
www.admiraalit.nl 2020-12-01 17:55:49

Associations of a parent class with other classes are implicitly inherited by the subclasses. The inherited associations should not be drawn explicitly in the diagram.

It does not matter whether the parent class is abstract or not.

In your example diagram, Player and Enemy have associations with DrawingClass.

Be careful if you add multiplicities to the association ends. For example, if the association in your example is a 1:1 association, then each DrawingClass instance is connected either to a Player or to an Enemy (or, if Entity is not abstract, to a direct instance of Entity), not to both.