3

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?

berimbolo
  • 3,319
  • 8
  • 43
  • 78

2 Answers2

3

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

bruno
  • 32,421
  • 7
  • 25
  • 37
  • One thing to note is that in the instance where a user creates an absence they would need to search for the employee as part of the create absence process.That is that without finding an employee as part of the process its not possible to create an ansence for an employee. With this in mind, which wasnt clear from the original post do all of your answers still hold true? Or would it just be that search for employee is a pre-condition to create absence? – berimbolo Mar 23 '21 at 11:13
  • I do not understand what you mean. `in the instance where a user creates an absence they would need to search for the employee as part of the create absence process`: in the instance of what ? the user creating the absence is not the employee ? The actor activating the UC *create absense* does not do that for himself ? `That is that without finding an employee as part of the process its not possible to create an ansence for an employee` : in that sentence the two words employee are the same actor or not ? – bruno Mar 23 '21 at 11:57
  • No, an administrator user creates the absence on behalf of an employee who is calling in sick or has submitted a leave request. The employee in this scenario is not someone who has access to the system in question and so is not being modelled as an actor right now. – berimbolo Mar 23 '21 at 12:03
  • 1
    @berimbolo oh yes, sorry I was wrong in my remarks, but my answer is right and unchanged. The fact the UC *create absence* contains or not the search for an employee is your choice, but for me the name of the UC indicates the employee was already found and you know an absence must be created, else better to name the UC like *create needed absences* (plural) because when the UC is activated the possible employees for whose an absence must be created are unknown. Anyway warning, use cases describe *what* the system has to do on external stimulus, not *how* it does (implementation) – bruno Mar 23 '21 at 12:29
  • 1
    That's great thanks, I am modelling them as your post suggests, separate use cases with no includes relationship between them, for one it makes more sense after speaking to you, and two it is clearer to other people and avoid confusion as to what is actually happening. – berimbolo Mar 23 '21 at 12:38
  • So I questioned the material being taught and was told by the lecturer "However the understanding of the "include" relations where the included use cases never stand alone, which means they by themselves will not deliver a valuable goal to the user. ". This seems to contradict both answers I received here, as I am now being told that only a use case with extends is standalone... I am even more confused now - "The extended use cases on the other hand are standalone which means they by themselves deliver something valuable to the user." – berimbolo Mar 29 '21 at 20:12
  • @berimbolo standalone means directly stimulated by an actor, by definition these UCs have a valuable goal for the actor ... else the UCs are not well defined. You can have included UCs whose are never standalone (e.g. directly stimulated), the goal is to have them included in several other UCs to not have to repeat several times the same thing in the UCs description, and not more. In fact the problem is when you have a standalone UC included in only one other UC : in that case the included UC has no sense and must be merged in the including UC. – bruno Mar 30 '21 at 08:20
  • @berimbolo It is totally different for the extends, for example an extend is when the user press F1 to see help, that has a valuable value for user – bruno Mar 30 '21 at 08:20
  • So can you have a use case that is included by some other use case, but is standalone? The lecturer was insinuating that the answer to this is no, included use cases cannot stand alone... – berimbolo Mar 31 '21 at 07:53
  • 1
    @berimbolo if it is only included it is not standalone. A priori there is nothing against the fact an included UC can be also standalone (so stimulated by an actor), but this is probably rare – bruno Mar 31 '21 at 08:34
  • Ok yes this is what I meant, so a use case that is both a stimulated by an actor but also an included usecase, I think the answer is yes, but it is not common? – berimbolo Mar 31 '21 at 08:55
  • @berimbolo yes for me this is not common, you can search questions on S.O. with the tags use-case to see if you find some – bruno Mar 31 '21 at 10:42
3

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.

Axel Scheithauer
  • 2,758
  • 5
  • 13
  • Ok can you give an example, using your description of when you would use <>? Also I find your post quite confusing and maybe it is because I am new to UML whilst not being new to programming, but first of all you ask me to not talk about triggering or invoking but then you talk about functions quite a lot, so I am not entirely sure in which context you are using the word "function", is it in terms of a function written in code or a more general term here? – berimbolo Mar 23 '21 at 22:29
  • The reason I originally thought I could use includes like that is because the example video I was watching which used an ATM example had an included "Validate Pin" use case off of a use case "Enter Pin", and I took that to just mean that whenever a pin was entered then it was always validated and so in my example I had thought I could show that whenever a holiday record was entered a person was searched for. I took it too literally I suppose. – berimbolo Mar 23 '21 at 22:34
  • Also are you saying that actually "Search For Employee" is not a use case at all but it should just be a function\method? – berimbolo Mar 23 '21 at 22:37
  • A good example for «include» is the use case `buy train ticket` for a `train ticket vending machine`. In order to buy a ticket, you have to `find a train connection`. Finding a train connection is useful in itself, since I might want to plan a trip and get information about the options before deciding about the trip. Or after having bought the ticket, I might change my plans and look for another connection. – Axel Scheithauer Mar 24 '21 at 08:32
  • 1
    Many texts about use cases have much too low criteria about what makes a valid use case. I'm keeping it with Alistair Cockburn in "Writing effective Use Cases", who said that a use case describes how a system delivers value to the user (or other stakeholder). So `validate Pin` is just an instrumental goal, that in itself has no value. I care about this only so far, as it is a step to reach my final goal of retrieving money. – Axel Scheithauer Mar 24 '21 at 08:39
  • `Search For Employee` can be a use case, but only for a very low level data base system. If you are analysing a `Human Resources Management System`, then `Search For Employee` would not be the reason, why you use the system. And these reasons are the gist of use case analysis. – Axel Scheithauer Mar 24 '21 at 08:47
  • I use the word "function" here as in "functional requirement". It can mean that your code shall include such a function. Depending on your programming language, you might call it by different names, such as "procedure", "method", "operation", "behavior", "transition" or the like. – Axel Scheithauer Mar 24 '21 at 08:58
  • Ok so hopefully my last question, if searching for an employee is not something I should create a use case for (I think that is what you are saying) how does it differ from finding a connecting train in your example of booking a ticket? In the system in question a user wants the ability to find an employee to view their record, or add a sick or leave absence for them. I am just confused because find\search for person seems to be a fundamental aspect of a HR system but are we saying this is too low level to bother modelling in a use case diagram? – berimbolo Mar 24 '21 at 12:04
  • 1
    Are you searching for an employee and then close the application? Or are you searching for an employee to add a sick or leave absence or change his/her wage or role or... A use case tries to capture why a user needs the system. Just searching for an employee for no purpose often doesn't add value, finding a new train connection does, at least if you missed your original train. An additional guiding principle is, whether the use case helps me find new functions. `search employee` is already a function, nothing new can be learned from analysing a use case `use function "search employee"`. – Axel Scheithauer Mar 24 '21 at 12:29
  • I think this now makes a lot of sense, and I know this is getting long but.... as a very final question\clarification - There is no need to show things like "Validate pin" or "Validate Credentials", or even "User Not Found Error" as use cases on a use case diagram? – berimbolo Mar 24 '21 at 13:25
  • 1
    No. Such things are steps of the use case that usually involve functions of the system. How you describe the steps of the use cases is a methodological question. Some authors suggest tables for basic flow and alternative flows, others prefer interaction diagrams. I usually use activity diagrams, since they allow to show all the alternative flows in one picture. – Axel Scheithauer Mar 24 '21 at 13:32
  • Would you disagree or agree with this statement "However the understanding of the "include" relations where the included use cases never stand alone, which means they by themselves will not deliver a valuable goal to the user. They together with the including use case will deliver something valuable to the user."? It seems your explanation of an includes case can stand alone, I don't see anything in the referenced standards in the answer above which actually says an included use case cannot stand alone – berimbolo Mar 29 '21 at 20:16
  • 1
    The specification only knows one definition for „use case“. A mandatory component of this definition is, that a use case has a result of value. That means that an included use case must also have this. Now, some say that reaching an intermediate goal has already value even though it cannot stand alone. There are two problems: Which intermediate goal deserves being analysed by a use case and which not? How to distinguish a use case that can stand alone from one that cannot? I sometimes use a stereotype «secondary» for the latter and only create it, if more than one use case needs to include it. – Axel Scheithauer Mar 29 '21 at 23:43