I came across this problem/question when designing a DCD. I have a generalization products and 2 specializations milk and pizza. I have doubts about if should use the aggregation between the order and product or order and pizza/milk.
I have simplified the uml to make my question as clear as possible.
Both diagrams are correct, but have a very different meaning:
Cake
without changing the meaning of the order (it is said to be "open for extension").Cake
), the definition of your order would have to be modified.Considering the Open-Closed Principle the first diagram is definitely the one to chose. The second one is too cumbersome.
Remark: by the way, while aggregation is still very popular for historical reasons, the UML specifications don't define its semantic. You could therefore remove the white diamonds and express exactly the same meaning.