SEN2022 · Week 6 · Use Cases and Use Case Diagrams

Use cases and use case diagrams

Actor, use case, system boundary, and the include, extend and generalization relationships. On the exam a scenario is given and you are asked to extract the actors and use cases and draw the diagram.

use caseactorprimary actorsecondary actorsystem boundaryassociationinclude relationshipextend relationshipextension pointgeneralizationuse case diagramsubjectstakeholder

The use case model is the start of functional modeling: it shows what users want to do with the system. The diagram itself is simple (stick figures, ovals, lines), but marks are lost on the exam precisely over details: mixing up include and extend, drawing the arrow the wrong way, making a step into a use case, mistaking data for an actor. A typical exam question: a paragraph scenario is given and you are told “Identify the actors and use cases and draw the use case diagram”.

Golden rules:

  1. An actor is a role, outside the system. It can be a person, an external system or time.
  2. A use case is a goal that gives value to the actor. Its name is verb + object: “Book Class”.
  3. Include is mandatory, extend is conditional. The include arrow goes from the base to the included one, the extend arrow from the extending one to the base.
  4. Generalization is a solid line with a triangle head, from the bottom to the top.

Basic elements

ElementNotationMeaning
ActorStick figure (or an <<actor>> box)A role interacting with the system
Use caseOval, with a name insideA goal for the actor
System boundaryRectangle, with the system name on topScope
AssociationSolid line (actor - use case)The actor takes part in this use case
IncludeDashed arrow, <<include>>Mandatory shared part
ExtendDashed arrow, <<extend>>Conditional additional behavior
GeneralizationSolid line, hollow triangle head“Is a kind of” relationship

Actor

An actor is a role outside the system that exchanges information with it. Three points to watch on the exam:

  • A role, not a person. Not “Professor Ahmet” but “Instructor”.
  • External systems are actors. The payment provider, the university’s student information system.
  • Time can be an actor. The “Time” actor that starts automatic jobs such as “generate a report at the end of every month”.

A primary actor is the actor that starts the use case and gets value from it. A secondary (supporting) actor is the actor from which the system gets help to do the job (e.g. Payment Service).

Use case

A use case is a complete goal that the actor accomplishes with the system and at the end of which they can say “I’m done”. Check questions:

  • Does it give the actor a valuable result?
  • Is it completed in a single session (in one go)?
  • Is it in the actor’s language or in technical language?

Good: “Reserve Book”, “Pay Fine”, “Track Order”. Bad: “Login Screen” (a screen), “Validate Input” (a step), “Database” (a technology).

Relationships

Association

The solid line between an actor and a use case. It shows that the actor takes part in this use case. An arrowhead is not required. Optionally, multiplicity can be written.

Include

The shared behavior that several use cases need every time is extracted into a separate use case. The base use case cannot be completed without the included one.

(Book Class) - - <<include>> - -> (Verify Membership)
(Check In)   - - <<include>> - -> (Verify Membership)

Extend

Behavior added to the base use case only under a certain condition. The base use case can also be completed without the extension. The extension point can be named inside the base use case.

(Pay Reactivation Fee)
      - - <<extend>> - -> (Renew Membership)
  condition: membership ended more than 30 days ago

PITFALL · arrow directions. Include: “Book Class includes Verify Membership” → the arrow leaves Book Class. Extend: “Pay Reactivation Fee extends Renew Membership” → the arrow leaves Pay Reactivation Fee. Form the sentence, and the arrow starts at the subject.

Generalization

Actor generalization: The child actor inherits all the relationships of the parent actor. Front Desk Staff and Trainer are special cases of Staff.

Use case generalization: Special kinds of a use case. “Pay Fee” is general, “Pay by Card” and “Pay by Cash” are subtypes.

Front Desk Staff ---|>  Staff
Trainer          ---|>  Staff
(Pay by Card)    ---|>  (Pay Fee)

Here ---|> represents a solid line with a hollow triangle head.

Comparing include, extend, generalization

IncludeExtendGeneralization
When it runsAlwaysWhen the condition holdsThe subtype takes the place of the supertype
Is the base use case complete on its ownNoYesThe supertype may be abstract
Arrow directionBase → includedExtending → baseChild → parent
LineDashed, open arrowDashed, open arrowSolid, hollow triangle

Worked example: the FitHub gym

Scenario: “A person becomes a member at the reception through a front desk staff member. Members renew their membership online; if the membership ended more than 30 days ago, they pay a reactivation fee. Payments are taken through an external payment service. Members reserve places in group classes and cancel their reservations. They check in at the turnstile when entering the gym. For reservation and check-in, the membership is verified to be active every time. Trainers manage the class schedule. At the end of every month the system automatically generates a monthly report and sends it to the managers. Front desk staff and trainers share common tasks as staff.”

Step 1: Find the actors. Scan the nouns, select the roles that interact with the system.

CandidateAn actor?Why
Person / MemberYes: MemberRole
Front desk staffYes: Front Desk StaffRole
TrainerYes: TrainerRole
StaffYes: Staff (parent actor)Shared role
Payment serviceYes: Payment ServiceExternal system
End of monthYes: TimeA job triggered by time
TurnstileNo (in this solution)Counted as part of the system
Class schedule, reportNoData

Step 2: Find the use cases. Scan the verbs.

Use casePrimary actorNote
Register MemberFront Desk Staff
Renew MembershipMemberPayment Service secondary
Pay Reactivation Fee(extend)Conditional
Book ClassMember
Cancel BookingMember
Check InMember
Verify Membership(include)Shared mandatory
Manage Class ScheduleTrainer
Generate Monthly ReportTime

Step 3: The diagram.

+------- FitHub Membership System ---------+
|                                          |
|  (Register Member)                       |
|  (Renew Membership)<-<<ext>>-(Pay React. |
|        |                       Fee)      |
|  (Book Class)--<<inc>>-->(Verify         |
|  (Check In)----<<inc>>--> Membership)    |
|  (Cancel Booking)                        |
|  (Manage Class Schedule)                 |
|  (Generate Monthly Report)               |
+------------------------------------------+

Associations (from outside):
 Member ......... Renew, Book, Cancel, Check In
 FrontDeskStaff . Register Member
 Trainer ........ Manage Class Schedule
 Payment Service  Renew Membership
 Time ........... Generate Monthly Report
Generalization:
 Front Desk Staff --|> Staff
 Trainer          --|> Staff

Step 4: Check.

  • Is every actor connected to at least one use case? Yes. (Staff is a parent actor; if a shared use case is added, e.g. “View Member Profile”, it is connected to that.)
  • Is every use case reached by an actor or linked by include/extend? Yes.
  • There are 9 use cases inside the boundary. That is at the limit of readability; in a larger system it is divided into packages.

Where do use cases come from?

Use cases are derived from the functional requirements you gathered in week 5. Every functional requirement must be traceable to at least one use case (traceability). Nonfunctional requirements do not appear in the diagram; they are written in the “special requirements” part of the relevant use case description (week 7).

Common mistakes

Wrong ideaThe truth
An actor is a specific personIt is a role; one person can play several roles
A database or a report is an actorIt is data, inside the system
Include is conditionalInclude always runs; the conditional one is extend
The extend arrow leaves the baseThe extend arrow goes from the extending one to the base
Every screen or step is a use caseA use case is a complete goal; steps go in the description
Ordering use cases with arrows (first login then …)A use case diagram shows no order; order is in the activity/sequence diagram
Drawing the actor inside the boundaryAn actor is always outside
The generalization arrow from top to bottomFrom bottom to top, with the hollow triangle at the supertype

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

In a use case diagram, what does an actor represent?

  1. A specific person, e.g., 'Ayşe'
  2. A role played by a person, a system or time that interacts with the system
  3. A class in the design
  4. A screen of the application
Show answer
B) A role played by a person, a system or time that interacts with the system

An actor is a role, not a person. The same person can be both a Member and Staff. External systems (Payment Service) and time (Time, for automatic monthly jobs) can also be actors. An actor is always outside the system boundary.

Question 2medium

Food-delivery app: 'A customer browses restaurants and places an order. The customer pays online through an external payment gateway. A courier accepts a delivery and marks it delivered. Restaurant staff update the menu.' List the actors.

Show answer
Customer, Courier, Restaurant Staff, Payment Gateway

Human roles: Customer, Courier, Restaurant Staff. External system: Payment Gateway (a secondary actor, the system uses it). "Restaurant" and "menu" are not actors; they are data or concepts inside the system.

Question 3medium

For the same food-delivery scenario, list the use cases.

Show answer
Browse Restaurants, Place Order, Pay Online, Accept Delivery, Mark as Delivered, Update Menu

A use case name is verb + object: a valuable result the actor gets from the system. Six use cases come out. If Pay Online is a mandatory part of Place Order, it can be linked with <<include>>; Payment Gateway is connected to Pay Online.

Question 4easy

Both 'Book Class' and 'Check In' always need to verify that the membership is active. Which relationship models this?

  1. Extend
  2. Include
  3. Generalization
  4. Association
Show answer
B) Include

The shared behavior that several use cases use every time (mandatorily) is extracted as a separate use case and linked with <<include>>: Book Class → Verify Membership, Check In → Verify Membership.

Question 5medium

In an extend relationship, which way does the arrow point?

  1. From the base use case to the extending use case
  2. From the extending use case to the base use case
  3. From the actor to the use case
  4. There is no arrow
Show answer
B) From the extending use case to the base use case

The <<extend>> arrow goes from the extending (optional) use case to the base use case: Pay Late Fee - - -> Renew Membership. <<include>>, in contrast, goes from the base to the included one. Both are dashed arrows.

Question 6medium

'When renewing, if the membership expired more than 30 days ago, the member must also pay a reactivation fee.' Model the reactivation fee.

Show answer
A use case 'Pay Reactivation Fee' that <<extend>>s 'Renew Membership' (condition: expired > 30 days).

The behavior runs only when a condition arises: extend. The base use case (Renew Membership) can be completed even without this addition. The condition can be written as a note together with the extension point.

Question 7hard

Front Desk Staff and Trainer can both 'View Member Profile', and Trainers can also 'Create Workout Plan'. How can you simplify the diagram?

Show answer
Create a general actor 'Staff' associated with View Member Profile; make Front Desk Staff and Trainer specialize Staff (actor generalization); Trainer keeps its own association to Create Workout Plan.

Actor generalization: the child actor inherits all the use cases of the parent actor. The arrow is a solid line with a hollow triangle head, from the child actor to the parent actor. That way one line is drawn to View Member Profile instead of two separate lines.

Question 8easy

Which is a BAD use case name?

  1. Reserve Book
  2. Pay Fine
  3. Database Update
  4. Return Book
Show answer
C) Database Update

A use case is a valuable goal for the actor and is named in the actor's language with verb + object. "Database Update" is an internal technical operation, not a goal for the student. It is also a noun pattern, not a verb.

Question 9medium

In the gym diagram on this page, how many use cases are inside the system boundary?

Show answer
9

Register Member, Renew Membership, Pay Reactivation Fee, Book Class, Cancel Booking, Check In, Verify Membership, Manage Class Schedule, Generate Monthly Report. Total 9. The actors (Member, Staff, Front Desk Staff, Trainer, Payment Service, Time) are outside the boundary and are not counted.

Question 10hard

Why is 'Enter Password' usually not modeled as a separate use case?

Show answer
It is a step inside a use case (too small), not a complete goal that gives the actor value.

A use case diagram shows high-level goals. Steps like "enter password" or "press the button" are steps of the use case description. A diagram divided too finely (functional decomposition) becomes unreadable. Rule: the actor should be able to say "I'm done" when this use case ends.

Question 11easy

What does the system boundary rectangle show?

Show answer
What is inside the system (use cases) versus outside (actors); the scope of the system.

The system boundary (subject) draws the scope: what is inside is the functions we will develop, what is outside is the interacting roles. The name of the boundary is the name of the system (e.g. 'FitHub Membership System').

Verification: Conceptual and 'identify' questions; the actor/use case lists and relationship types were checked one by one against the UML 2 use case diagram rules (include: mandatory shared behavior, arrow from the base use case to the included one; extend: conditional behavior, arrow from the extending one to the base; generalization: hollow triangle from the subtype to the supertype). Counting questions were counted by hand on the diagram on the page and compared twice.

Review card

Actor = role (person, external system, time), OUTSIDE the boundary, stick figure Primary actor: starts the use case; secondary: the system gets help from it Use case = goal that gives value to the actor, oval, "verb + object" System boundary = scope box, system name at the top Association: solid line between actor and use case <<include>>: MANDATORY shared behavior; arrow base → included (dashed) <<extend>>: CONDITIONAL/optional behavior; arrow extending → base (dashed) Generalization: solid line + hollow triangle, child → parent (actor or use case) A child actor inherits all the use cases of the parent actor Step ≠ use case ("enter password" is a step) Actors are not counted, use cases are counted inside the boundary Ideally 3-9 main use case groups in one diagram