use case diagram extends includes

Mastering UML: Use Cases, Extends, Includes

By Joshua Taylor
AD

Use case diagrams are graphic models in software engineering that describe the behavior of a system from the perspective of its users. Among the many relationships that connect these use cases, two prominent ones are 'extends' and 'includes'. Understanding these relationships is key to effectively modeling a system's behavior. In this comprehensive guide, we explore the concepts of 'extends' and 'includes' in use case diagrams, providing real-world examples and best practices.

First, let's briefly overview use case diagrams. They visually represent the actors (users) of a system and their interactions with the system through use cases. Use cases are linked to each other and the system by various relationships, including 'extends' and 'includes'. These relationships help define how use cases interact and are a powerful tool for system analysis.

The 'extends' Relationship

The 'extends' relationship, denoted by an open arrow, indicates that a use case may be extended by another use case. This means that the behavior of the extending use case is incorporated into the extended use case. In other words, if the extended use case is performed, then the extending use case is also performed.

AD
Use Case Diagram | Learn UML | Omer Javed Articles
Use Case Diagram | Learn UML | Omer Javed Articles
How to create a use case diagram | moelgendy blog
How to create a use case diagram | moelgendy blog
Use Case Diagram Tutorial: What It Is and How to Create One | Creately
Use Case Diagram Tutorial: What It Is and How to Create One | Creately

Let's consider an e-commerce scenario. Suppose we have a 'Checkout' use case. This use case can be extended by a 'Guest Checkout' use case. This 'extends' relationship tells us that when a user checks out as a guest, the standard checkout process is performed, and additionally, the system records the guest's information for future use.

Extending Use Cases with Preconditions

It's essential to note that extending use cases can have preconditions. For instance, the 'Guest Checkout' use case might have a precondition that the system's guest functionality is enabled. This means the extends relationship only applies if the precondition is met.

Download Use Case Diagram for Library Management System
Download Use Case Diagram for Library Management System
Use Case Templates to Instantly Create Use Case Diagrams Online - Creately Blog
Use Case Templates to Instantly Create Use Case Diagrams Online - Creately Blog
UML Use Case Diagram for Airline Reservation
UML Use Case Diagram for Airline Reservation

In our e-commerce example, if the guest functionality is disabled, the 'Checkout' use case would not extend to 'Guest Checkout'. Instead, the system would prompt the user to log in or create an account, preventing an invalid 'Guest Checkout' action.

Extending Use Cases with credit:

Sometimes, you might want to give credit to another use case for extending the functionality. In such cases, you can use a 'credit:' label followed by the extending use case's name. For example, you might have 'Checkout' extend 'credit: Guest Checkout'. This means that the functionality provided by 'Guest Checkout' is incorporated into 'Checkout', but 'Guest Checkout' itself is not triggered.

AD

In this case, the system saves the guest's information after the completion of the standard 'Checkout' process, recognizing the contribution of the 'Guest Checkout' use case without actually executing it.

UML Use Case Diagram
UML Use Case Diagram
Use Case Diagram for E-Commerce Websites
Use Case Diagram for E-Commerce Websites
Use Case Diagram of Appointment System
Use Case Diagram of Appointment System
a diagram that shows the flow of different items in an organization, including two people and one person
a diagram that shows the flow of different items in an organization, including two people and one person
Student Management Use Case
Student Management Use Case
Use Case Templates to Instantly Create Use Case Diagrams Online - Creately Blog
Use Case Templates to Instantly Create Use Case Diagrams Online - Creately Blog

The 'includes' Relationship

The 'includes' relationship, denoted by a dashed arrow, indicates that a use case includes the behavior of another use case. This means that the included use case is part of the including use case's behavior, but they can be invoked independently.

Consider a library management system. Here, the 'Return Book' use case could include the 'Update Book Status' use case. This 'includes' relationship means that when a book is returned, its status is updated. However, if a librarian needs to update the status without actually returning the book, they can invoke 'Update Book Status' independently.

AD

Including Use Cases with Postconditions

Including use cases can have postconditions. For instance, 'Update Book Status' might have a postcondition that sends a notification to the appropriate librarian. This means the 'includes' relationship only applies if the postcondition is met.

Use Case Diagram for Banking System | Creately
Use Case Diagram for Banking System | Creately
Use Case Diagram Tutorial: What It Is and How to Create One | Creately
Use Case Diagram Tutorial: What It Is and How to Create One | Creately
Usecase diagram
Usecase diagram
UML Use Case Diagram Tutorial with Examples
UML Use Case Diagram Tutorial with Examples
UML Use Case Diagrams: Tips
UML Use Case Diagrams: Tips
university use case diagram
university use case diagram
Use Case Diagram for Online Food Delivery System
Use Case Diagram for Online Food Delivery System
Shop System Use Case Diagram
Shop System Use Case Diagram
Student Attendance System | Creately
Student Attendance System | Creately
Sistema de cajeros (caso de uso) (es) | Creately
Sistema de cajeros (caso de uso) (es) | Creately
Library Management System | Creately
Library Management System | Creately
a diagram with several different types of data
a diagram with several different types of data
a diagram that shows the different types of data flow in an organization's workflow
a diagram that shows the different types of data flow in an organization's workflow
Online Examination System
Online Examination System

In our library example, if the system is not connected to the notification service, the 'Return Book' use case would still update the book status, but the notification step would be skipped.

Including Use Cases with 'credit:'

Similar to 'extends', you can use 'credit:' with 'includes' if you want to give credit to the included use case without actually invoking it. For example, 'Check In Book' might include 'credit: Update Book Status'. This means that the functionality provided by 'Update Book Status' is incorporated into 'Check In Book', but 'Update Book Status' itself is not triggered independently.

AD

In this scenario, the system updates the book status when a book is checked-in, recognizing the contribution of 'Update Book Status', but the 'Update Book Status' use case is not invoked on its own.

Understanding and correctly using 'extends' and 'includes' in use case diagrams can significantly enhance the quality and comprehensibility of your software models. By incorporating these relationships into your design, you can create more accurate, engaging, and ultimately more useful models for your team and stakeholders.

As you continue your exploration of use case diagrams, remember that these tools are meant to be dynamic and adaptable. Don't hesitate to refine and adjust your models as your understanding of the system deepens. After all, the path to exceptional software engineering is a journey, not a destination. Happy modeling!

AD