umlrelationshipclass-diagramobject-oriented-analysis

On which side shall I put the diamond sign in an UML diagram


img1

I am trying to figure out where should the diamond be placed in this example, I understand its a has-a relationship and diamond should be placed to indicate the whole and part relationship. I have created the UML so that the diamond is on the manufacturer side for both car and engine, like below

img2

because it makes sense right? that the car and engine is being produced by the manufacturer, but the correct answer I was given in the class was to put the diamonds on car and engine respectively... it seems a bit odd to me since wouldn't the manufacturer be the "whole" in this relationship? Below is the spec:

img3

I am trying to figure out where should I place the diamond sign


Solution

  • The diagram of the top is wrong, given the specifications:

    If the top diagram is what was taught in the classroom, the teacher has not understood UML very well, and you should consider a different guidance.

    The diagram on the bottom is correct about the side of the diamond, but I'd recommend not to use composition at all. Here the comments to the second model: