modeling polymorphism in UML - dependency to abstract classes

Viewed 270

I have searched many hours over the course of the last few semesters trying to make sure that I am presenting this correctly to my students. Nothing I have found shows this particular relationship. This semester I'd like KNOW that I'm doing it correctly.

We have an abstract class, Player and two concrete classes that extend it (Pitcher and PositionPlayer). Then we have a class, Team with a map declared to be

    <Integer, Player>  

To me it seems that Team is dependent on Player (the abstract class) but I suppose dependence could be shown for the subclasses. Please tell me which of these is correct, the top one or the bottom one? (my UML editor won't do italics, hence the tags). Thank you in advance for your help.

enter image description here

2 Answers

Both are correct. The top is more general and the bottom one more specific. But both tell the same.

The following is to show where you would use the lower part of your design. If you have a third Player subclass which Team does not dependent on you use the lower representation - without a dependency to the new subclass.

enter image description here

Might not be very realistic, but that could be some fictive game constellation.

If Team contains an attribute of type MAP, for me, it means that Team contains a list of player, each one identified by an id.

If Team contains an attribute of type Player with a cardinality 0..n, it means, that Team is associated with Player.

Since each Player is identified by an integer, for me, this is a qualified association.

enter image description here

Related