15

The most likely answer is no, but I've come with this doubt. Can an actor act as a class?

I know actors trigger events and can have prompts, but if there's a class modeling an actor (such as an user class) can we call methods over them? Or is this a complete misunderstanding of the actor role, which is getting mixed with the representative class?

Supposed as correct:

Supposed Correct Example

Doubt if correct:

enter image description here

1 Answer 1

11

In UML, an Actor is always something (a system or person) that is outside the scope of the system/software that you are building. It would be completely wrong to equate an actor with an instance/object of a class that happens to model certain aspects of the actor in your system.

In the shown UML diagrams, the actor "User" (with it's stick-figure icon) represents the real-world human being that operates your system. The class User represents a model of that person that captures the characteristics that are relevant for you. This class only exists within your system.
This makes that the class and the actor are two distinct entities and should also be shown as such in your diagrams.

4
  • 1
    "Actor is always something outside the scope of the system/software that you are building." Nevertheless the actor interacts directly with the object of some Class by initiating the call stack. Therefore he somehow is a part of the system (he is represented by another arbitrary class from a UI layer that is most likely not modelled by the class diagram). This seems really counterintuitive at first and is probably the source of confusion for some folks.
    – dvdblk
    Commented Nov 28, 2018 at 16:05
  • 1
    Actor is a separate entity. Actor exists even if the system does not. Actor initiates, shuts and even provides input to the system but does not sit inside the software system to perform any task of the System. System works independently of actor. Objects can simulate real world actors but still depend upon human actors for start-up, exit and input directly or indirectly. Commented Mar 1, 2020 at 17:29
  • @Bart van Ingen Schenau: Hence the actor interacts with some class and provides information. Class calls methods of user object (representing actor in the system) to process or store information. But can Actor directly communicate with his representation in the system? can actor get replies from the class he is interacting with? (e.g. confirmation of an appointment)
    – Afia R. S.
    Commented Oct 26, 2021 at 17:51
  • @AfiaR.S., that depends entirely on the system you are building. If you are building a software library, then the actor is another piece of software and that can directly interact with classes/objects within your system. If you are building something to interact with a human user, then the interaction always goes through a UI component of some form. Commented Oct 27, 2021 at 5:36

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.