UML diagrams: use case diagrams in detail

Introduction to Use Case Diagram

Use case diagram

  • The use case diagram is applied in the requirement analysis stage of software development. It describes the function of the system and how to use a system
  • The use case diagram shows who will be the relevant users, what services the user wants the system to provide, and the services the user needs to provide for the system
  • Use case diagrams are most commonly used to describe systems and subsystems
  • Use case diagrams are divided into business use case diagrams and system use case diagrams
    Insert picture description here

Composition of Use Case Diagram

The use case diagram mainly contains the following 6 elements

  • Actor
  • Use Case
  • Association
  • Include relationship (Include)
  • Extend
  • Generalization

1. Participants

Participant's concept:

  • An external entity
  • Participate in the execution process of the use case
  • Participants are represented by the roles they play when participating in the use case
  • Each participant can participate in one or more use cases
    Insert picture description here

Types of participants

  1. System users
    Real people, namely users, are the most commonly used participants. They exist in almost every system. When naming such participants, they should be named according to their roles.
  2. Other systems
    that interact with the system being built External programs
  3. Time agent
    For example, in the car rental system, when the customer has not returned the car at the time of return, the system will remind the customer service representative to call the customer, and then time becomes a participant in the system
  4. Others such as: hardware equipment, external services and external databases, etc.

How to find participants in the system?

  • Who will use the main functions of the system
  • Who will need the support of the system to complete their work
  • Who will need to maintain and manage the system
  • What hardware devices need to be handled by the system
  • What system is interacting with this system
  • Who or what system is interested in the results produced by this system

The initiator and the supporter The
initiator is the main service object of the use case. The
other is
Insert picture description here
the relationship
between the participants who play the role of the supporter . The participants can have generalization relationships.
In the use case diagram, the generalization relationship is used to describe multiple Public behavior

Insert picture description here

2. Use case
What is a use case? The
externally visible system functional unit defines coherent behavior without revealing the internal structure of the system, not the specification of requirements or functions.
Use case representation

  • Simple Name
  • Path Name
    Insert picture description here

How to identify use cases

  • What features do specific participants want the system to provide
  • Whether the system stores and retrieves information
  • When the system changes state, whether to notify participants
  • Whether there are external events affecting the system
  • Which participant notifies the system of these events

Use Cases and event stream
analysis in system requirements analysis phase use cases, this stage should avoid the details regardless of the system, but to actually build the system, you will need more specific details, these details written in the event stream file cases in the corresponding
event stream The description is independent of the implementation method, the event flow describes the system "what", not "how"

The composition of the event stream file

  • Brief description Description
    related to the use case, describing the role of the use case
    should include the participants who execute the use case and the results to be achieved through the use case
  • Prerequisites Conditions
    that must be met before the use case is executed, for example, another use case must be executed first
  • Postconditions
    things that must be done after the use case is executed, such as another use case must be executed
  • The event flow (main event flow, other event flow, error flow)
    describes the specific steps of the execution of the use case from the user's perspective,
    including the beginning and end of the use case, how the use case interacts with participants, the normal flow of the use case, the variants of the main event flow, and errors flow

Insert picture description here

The relationship between use cases

Association

  • Represents the relationship between participants and use cases
  • Different participants can access the same use case

Insert picture description here
Include relationship (include)

  • A use case can simply include the behaviors of other use cases, and take the behaviors it contains as part of its own behaviors. This is called the containment relationship between the role cases.
  • The containment relationship separates the common parts of several use cases into a single contained use case. The contained use case is called the provider use case, and the containing use case is called the customer use case.
  • The customer use case can simply include the behavior of the provider use case, and the use case behavior it contains as part of its own behavior
    Insert picture description here

Features of containment relationship:

  • Include use case (customer use case) execution, then included use case (provider use case) must be executed

When to use containment relations?

  • If two or more use cases have a large number of consistent functions, this function can be decomposed into another use case, and the other use cases can establish a containment relationship with this use case
  • When a use case has too many functions, the containment relationship can be used to model more than two use cases to reduce the complexity of the use case

Extend

  • Extended use cases are defined as incremental extensions of base use cases
  • Extending the relationship is adding new behaviors to existing use cases
  • Basic use cases provide extension points to add new behaviors
  • The extension use case is inserted into the extension point of the base use case

Insert picture description here
Characteristics of extended relationships

  • There is no basic use case, and the extended use case is also a complete use case
  • When the basic use case is executed, the extended use case is generally not involved. Only when certain conditions occur, the extended use case may be executed. This is the difference from the containment relationship

Insert picture description here
Generalization

  • Generalization relations are general and special relations
  • A use case (parent use case) can be specifically enumerated as one or more child use cases
  • The child use case represents a special form of the parent use case
  • The child use case inherits behaviors and attributes from the parent use case, and can also add behavior or override or change the inherited behavior
    Insert picture description here

If one or more use cases in the system are specialized use cases of a general use case, the generalization relationship of the use cases should be used, for example:

Insert picture description here

Example of use case diagram:

Use case diagram for library administrators to handle borrowing and returning books Use case diagram for
Insert picture description here
system administrators to perform system maintenance

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41784749/article/details/112235707