Hi, Can can someone please comment on my answer for the following question from mock exam? Refer to the exhibits to answer the question. What are the names of missing classes XXX and YYY in exhibit below ? (choose one) a) XXX = DeliverySchedule, YYY = Supplier b) XXX = Supplier, YYY = DeliverySchedule c) XXX = PreferredSupplier, YYY = DeliverySchedule d) XXX = DeliverySchedule, XXX = PreferredSupplier I chose the answer (b), but I have some doubts that (c) could be correct too. Please let me know your choice on this one and any reasons that you could offer.
MM Koppula<br />SCJP2<br />Object Oriented Analysis and Design with UML (IBM)
I believe it's (c). The reason: Every product item can be fulfilled by several Suppliers depending on location. This is from the assoc.
We also know that every product can be fulfilled by at most one supplier. (b) only works if there's a one supplier per product. Undoubtedly for the case where there's more than one supplier; you need some differentiation on who is selected.
Merlin M Koppula
Joined: Jan 18, 2002
Pho, Your logic makes sense. I guess we have to assume that there is always going to be a preffered supplier from the list of suppliers for a location. So, the nextDeliveryFor() message is never sent directly to Supplier object. Thank you very much.
TelusJoe, You raised an important point. In the generalization from Supplier to PreferredSupplier, there are no multiplicity indicators. Can you attach (in UML) a multiplicity indicator to generalizations ? What does the non-existence of such indicators mean ?
Pho [ February 18, 2002: Message edited by: Pho Tek ]
I would vote for Preferred Supplier instead of Supplier since there is a possibility that the Supplier class is abstract and one cannot instantiate abstract classes. On interaction diagrams one would normally expect to see only instantiated objects. Am I right ? Makes sense but I am not sure.
I believe the correct answer for this question is (b) Supplier. Supplier is not an abstract class, not in this diagram so the object in the sequence diagram may be both, Supplier OR PreferredSupplier. From the diagram we can't conclude that each Supplier has to be a PreferredSupplier, only the opposite way, so putting in Supplier is correct for every concrete Supplier-Object.
And, about multiplicity of generalizations, I'm pretty sure that you can't do something like that in UML. Multiplicity belongs to assoziations, it tells something like Class A has/knows one or many B's. How could you read this for a generalization? Class A is many B's? Makes not much sense to me. Chris
Joined: Feb 05, 2002
Good point but ... The relationship between InventoryProduct and Supplier is many-to-many. This means that the InventoryProduct object has to select a Supplier from a list of suppliers before it can send any message to it. How would the InventoryProduct object identify its supplier ? But if we assume that the InventoryProduct somehow knows its preferred supplier then it can directly send a message without going through a selection process.
It is b) given that there may not be a PreferredSupplier for every InventoryProduct.
Joined: Feb 05, 2002
If you didn't have a preferred supplier how would the anInventoryProduct select "the" supplier from a list of many suppliers ? Since the diagram does not indicate selection of a specific supplier from the list of suppliers I still think that the answer is C.
Joined: Feb 26, 2002
nextDeliveryFor is an operation defined on Supplier. Hence b should work for either objects (possibly through dynamic binding).