2

I am trying to understand the relationship between actors and their representation in the system. Please see the below figure

enter image description here

In the figure on left, I have an abstract representation of my system. In the figure on left, I have a more detailed representation, such that the class Guest is supposed to represent the actor guest in my system. The scenario is that the guest would provide his user name and password, this is validated by system, and then he selects room r1 to book.

Question 1: In the left figure, is it correct to have the actor send method calls to my system and my system send it messages such as confirm or select room? Should such messages follow a specific format?

Question 2: In the right figure, I have representation of my actor as class Guest. I am not sure how represent the messages exchanged between my classes and actor. I greatly appreciate any help.

2
  • Have you thought about how you would actually write this program? The point of drawing diagrams is to write better programs - not just to draw diagrams. For example, what is the point of the SelectRoom() message in your second diagram, and how does the room know when to send it, and how does the user know their booking is confirmed?
    – user20574
    Commented Oct 27, 2021 at 16:18
  • Have a look a system sequence diagrams, a way to do high level modeling of systems with actors. Messages to actors aren't methods, but feedback through the UI. Similarly, an actor can't send a message, but a UI can, after the user interacts with it. This kind of diagram assumes there's a UI, which could be graphical or voice recognition or other software to recognize actor gestures. Commented Oct 28, 2021 at 13:01

2 Answers 2

1

Formally speaking, an actor is external to the system, and a sequence diagram is enclosed in a classifier of the system. You should therefore not have an actor in the sequence diagram.

It is however a common and accepted practice to document user-interaction scenarios with sequence diagrams. It remains very ambiguous, since the semantic of messages is not defined for human users (e.g. are operations like selectRoom() really defined for a user? what does synchronous/asynchronous message mean with a user?) and moreover humans do not interact using an API directly. It would be less confusing to replace named messages to describe the interaction steps in plain text (ask to select the room instead of selectRoom()).

Finally there are some cases where the diagram such as on the left is less ambiguous: an actor is not always a human. It can be another system interacting using an API. Nevertheless, if you'd choose to show an interaction in a system of systems, all the involved classifiers should be represented (in theory at least) as a part and not as an actor.

2
  • Thanks. It was my understanding that at conceptual level (requirements spec) it is ok to use actor interacting with the system, to enable customers to understand better. For design level, it is my understanding that we need to have something similar to one on the right. Based on your feedback, then I guess I need to remove the actor and let the class guest interact with other classes to reserve a room??
    – Afia R. S.
    Commented Oct 28, 2021 at 3:05
  • @AfiaR.S. yes, indeed. Guest presents probably the user interface (i.e. boundary as in EBC)
    – Christophe
    Commented Oct 28, 2021 at 20:12
0

The point of these diagrams is to help you write a program, not just to draw diagrams for the sake of drawing diagrams.

The left diagram tells me what the user is doing to the system. Of course the user is not literally calling a GetName(ID, Pass) function, but they are doing something equivalent, like typing in their ID and password and clicking the button Log In. For this purpose we don't care about such details.

The right diagram is obviously an attempt to explain what is happening inside the system. However, it is not equivalent. The user gets no feedback. The user never gets told that it's time to select a room, and the user never gets told that their booking is confirmed. Inside the system, the :Guest_Class: is being told these things, but that's inside the system, and the user never sees it.

The diagram is meant to correlate somewhat with the software (that's how it helps you plan the software). Will your software have a :Guest_Class: in it? It doesn't sound like a way that real software would actually work. I suspect that in reality the user will interact with the :Login and then once they are logged in, the user will interact with the :Booking, which will find a free :Room, and record the booking in the :Database, and the :Payment, which will send some messages to the Credit Card Processor. Something like that.

Note that (in my experience) real business software tends to be built more around systems and not-so-smart records. The Room wouldn't accept the booking request; rather the BookingSystem would accept the booking request and then tell the Room to remember that it's booked. Except Rooms aren't always real objects either - it is even more likely that there is a Database which stores all the information about rooms, and the BookingSystem will send messages to the Database like "save the fact that room #1234 is now booked by John Doe"

3
  • Thanks for your comments. I am very new at this, and I will think about your answer more and reply. I only represented the class guest inside the system as I think guest details are registered separately from their bookings. E.g., in a database table, we would have a separate table for guests. Am I confusing database design with OO?
    – Afia R. S.
    Commented Oct 27, 2021 at 18:01
  • In the noun extraction method, we need to extract nouns which may be classes. That is one of the reasons I assumed guest would have a class.
    – Afia R. S.
    Commented Oct 28, 2021 at 3:08
  • @AfiaR.S. That is a good point, your software probably will have a guest class, but it's just a record about a guest, it's not the guest itself and it doesn't have anything to do with clicking things on the screen. Perhaps the user interface will tell the guest object that it has now booked a room, and tell the room object that it is now booked.
    – user20574
    Commented Oct 28, 2021 at 16:17

Your Answer

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

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