If, for example, I have the following requirements: 1. Dog is an Animal 2. Zoo has Animal(s) Do I still need the 2nd diamond connector (the lower one) as shown here:
开发者_如何学PythonThe 2nd diamond connector is redundant. Here is some advice about UML class diagrams style: http://www.agilemodeling.com/style/classDiagram.htm
The 2nd diamond connector suggests that in addition to animals the Zoo also has specifically Dogs.
Hi before tackling UML use your common sense :)
Do you want to model that zoo have animals of different species ? Then you should not only put dogs but also cats and all other animals class that can exist in THIS zoo type (class) and just use one diamond connector.
Don't use white diamond connector. Use either "composition" or "association". In your case, use "association". The author of "UML distilled" has following comments.
The second aggregation is not necessary. However, you can change your model in this way:
(1) Set the first aggregation's target role (at Animal side) "animals".
(2) Delete the second aggregation.
(3) Create another class DogZoo, generalize from Zoo.
(4) Draw an aggregation from DogZoo to Dog, with the target role "dogs {redefines animals}"
Hope that helps.
精彩评论