Ju Ju
Ju Ju

Reputation: 199

difference between two diagrams

enter image description here

Here is the exercise question I want to solve out. A customer places an order with a supplier. The order is for various numbers of different kinds of parts; the distinction between different kinds of pans can be ignored for the purposes of this exercise, An order consists of a number of order lines; each line specifies a particular part from the suppliers catalogue, and says how many are to be ordered. In response to an order, the supplier makes up a delivery, consisting of all the ordered parts. Describe this situation in a class diagram, and discuss the possible use of aggregation in your diagram.

The first diagram is the suggested answer and the second diagram is my own answer.

  1. Is it appropriate to use Orderline as an association class?
  2. Isn't it enough to use association between Order and Delivery classes to make up a delivery? The information which part should be delivered can be retrieved since the Order class is associated with the Part class. In the suggested answer, the class Part refers to the Part description found in the catalogue. The actual physical parts which comprise deliveries are represented by the class Item.
  3. What are the benefits of using different classes?

Upvotes: 0

Views: 647

Answers (1)

Ister
Ister

Reputation: 6318

First of all remember, that there is hardly ever only one correct" way of building a model. OrderLine can be modelled as a association class between Order and Part because that's exactly idea behind the association class. On the other hand as the description explicitly declares that Order consists of OrderLines you can also follow this way and model it as a separate class. However in this case it should be a composite aggregation rather than just an association. As for Item and Part - Part is a Catalogue position (and again it should probably be a composition rather than simple association) while Item represents actual deliverable object. However in some cases you wouldn't model it like that but still you would have to have some sort of "carrier" in a Delivery. What I miss on "original" diagram is a relationship (association) between OrderLine and Item to show which precisely OrderLine is realized by delivering which Item. That allows verification if all OrderLines were covered.

Upvotes: 2

Related Questions