Use case diagram: Does an included use case have to be triggered by the base use case?

Viewed 328

If I have an actor invoked use case such as "Create Absence" and every time the actor creates an absence they will need to "Search For Employee" is it correct to model this using an includes relationship?

This is the thing that is not clear in all explanations of includes, does the included use case have to be triggered automatically by the base or can it be used to show that every time an absence is created the user will always search for an employee.

Alternatively should both of these be modelled as actor invoked and with no includes relationship between them?

2 Answers

Please stop talking about use cases being triggered or invoked. A use case describes a case of using a system for a certain purpose. What is triggered or invoked can only be the functions of the system. Use cases help us to find these functions. If you use a hammer to nail a crate together, the nail crate together use case is not invoked on the hammer. Instead the store kinetic Energy function, the aim hammerhead function and the transfer energy to object function is invoked. By analysing the use case, we find that frequently nails will get bent, so we might find it useful to have a pull nail function.

Therefore, search for employee is a function, needed for the use case create absence. It is very likely, that other use cases will also need this function. Many functions are needed in more than one use case. The pull nail function for example comes in handy, when you want to open a crate.

So, I would use «include» only when I find two valid use cases, where the first one has a goal that is included in the second goal. And only when the included use case is worth an analysis. Otherwise just refer to the function. You already have a use case that describes the need for it.

By the way, in the context of use cases the UML specification always talks about "behavior". Please note, that it will write "Behavior" with a capital "B" when it is talking about the UML concept of Behavior. That means here it is used more in a colloquial sense. So, I wouldn't interpret the sentence about «include» as defining a precise semantics of it.

The standard is clear, from formal/2017-12-05 § 18.1.3.3 Includes page 641 :

Include is a DirectedRelationship between two UseCases, indicating that the behavior of the included UseCase (the addition) is inserted into the behavior of the including UseCase (the includingCase).

All of the behavior of the included UseCase is executed at a single location in the included UseCase before execution of the including UseCase is resumed.

so :

  • does the included use case have to be triggered automatically by the base : yes, even the way to say is not perfect because the included UC is not triggered but its behavior inserted

  • can it be used to show that every time an absence is created the user will always search for an employee: no, if UC Create Absence includes UC Search For Employee then user will not search after but during.

  • is it correct to model this using an includes relationship?: no then

  • Alternatively should both of these be modelled as actor invoked and with no includes relationship between them? : yes then, note you can have a post condition in UC Create Absence saying the actor will have to Search For Employee

Related