0

For this question:

Considering the following sequence diagram, it is CORRECT to state that:

enter image description here

Select one or more:

a. Message 4 might never be executed.

b. Message 5 is not complete until the Customer receives an message confirming creation of the ShoppingCart.

c. Message 7 corresponds to behaviour belonging to the ShoppingCart class.

d. Message 6 is an example of a timed event which can only take place after other messages have occurred.

e. Book and Bookshop are objects.

The correct options are A and C. But I believe the correct option is A and E. E should be correct because Bookshop and Book are clearly objects since they are enclosed in rectangular shapes. Why are options A and C correct and not A and E?

1 Answer 1

2

UML uses Name : Type notation. Both the name and the type can be elided when irrelevant. The : ShoppingCart label describes an unnamed object of type ShoppingCart. Since there is only one object of each type, it is not necessary to give names to the objects.

Thus, Book and BookShop are not objects. They are classes/types, and : Book and : BookShop indicate unnamed instances/objects of these types. Therefore, answer E is wrong.

The message7 is invoked on the : ShoppingCart object, which means that the ShoppingCart class provides such a method. Therefore, answer C is correct. In particular, the message7 is not part of the Customer class/type/actor.

10
  • I'm still confused, how do you know there is only one object of each type? Also you're saying if book and bookshop had names they would be objects? Apr 4, 2022 at 22:41
  • @computerscienceisapain Looking at the diagram I see one unnamed actor : Customer and three objects : Bookshop, : Book, and : ShoppingCart. Because of the Name : Type syntax I see that all of these objects have no name, but that they are instances of the classes Bookshop, Book, and ShoppingCart, respectively. So there is one object of each type. Having a name is not necessary for being an object. To muddle things further, classes are objects in the UML meta-model. Here, the : means that the box does not represent that class, but an instance of the class.
    – amon
    Apr 5, 2022 at 10:31
  • I echo @computerscienceisapain's confusion. To me, the terms "object" and "instance of a class" are interchangeable. The fact an object doesn't have a "name" is irrelevant, in my mind. Perhaps "object" in UML terminology means "a named instance of a class?" Apr 5, 2022 at 12:51
  • @GregBurghardt I'm not trying to make a distinction between “object” and “instance”.
    – amon
    Apr 5, 2022 at 13:09
  • Ok, I see the difference -- "e. Book and Bookshop are objects." is not referring to the vertical rectangle in the diagram. It refers to the horizontal rectangles. It's a matter of how the reader interprets the text. The horizontal rectangles with "Book" and "Bookshop" represent classes. The vertical rectangles under them represent the lifetime of the objects. I was focused more on the lifetime of the objects than the classes themselves. Apr 5, 2022 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.