use case diagram includes vs extends

Use Case Diagram: Includes vs Extends

By Jessica Anderson
AD

Use case diagrams in software engineering are potent tools for modeling and visualizing system behavior. Two crucial relationships in these diagrams are "includes" and "extends". While both serve to connect use cases, they do so in distinct ways, catering to different system behavior dynamics.

In the competitive landscape of software development, understanding these relationships is not just beneficial; it's a critical skill set to ensure systems are designed effectively, are maintainable, and meet the objectives of their stakeholders.

Includes Relationship in Use Case Diagrams

The "includes" relationship is a fundamental association between use cases. It's used to depict that a particular use case shares some functionality with another use case. This relationship is represented by a line connecting the two use cases with an open ball at the end closest to the use case being extended.

AD
Use Case Diagram | Learn UML | Omer Javed Articles
Use Case Diagram | Learn UML | Omer Javed Articles
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
How to create a use case diagram | moelgendy blog
How to create a use case diagram | moelgendy blog

Think of it like a recipe. Imagine "includes" as an ingredient. When baking a cake, you might include vanilla essence in your chocolate cake recipe. Similarly, in your system, one use case 'includes' another to share a common function, enhancing reusability and maintainability.

When to Use 'Includes'

Use 'includes' when you want to share functionality between use cases. For instance, if you're designing e-commerce software, you might have a use case 'Checkout'. This could 'include' the use case 'Validate Payment', which is also used in the 'Refund' use case.

UML Use Case Diagram Tutorial with Examples
UML Use Case Diagram Tutorial with Examples
Bank Transaction System | Creately
Bank Transaction System | Creately
Download Use Case Diagram for Library Management System
Download Use Case Diagram for Library Management System

Here's a simple example: Purchase Book use case includes the Search Books and Add to Cart use cases.

Pitfalls of Overusing 'Includes'

While 'includes' is a powerful tool, it can lead to complexity if overused. Be mindful of the Fan-In - the number of use cases that another use case includes. High Fan-In can indicate complexity and is a good candidate for refactoring.

AD

Feasible Fan-In values vary depending on the project's complexity, but use caution when including more than two to three use cases in a 'include' relationship. Regularly review and refactor your diagram to optimize 'include' usage.

Use Case Diagram for E-Commerce Websites
Use Case Diagram for E-Commerce Websites
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
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
UML Use Case Diagram for Airline Reservation
UML Use Case Diagram for Airline Reservation
What is a Use Case Diagram?
What is a Use Case Diagram?

Extends Relationship in Use Case Diagrators

The "extends" relationship is another pivotal connection in use case diagrams. It portrays a 'parent-child' association, where the child use case shares or adds functionality to the parent use case. This relationship is denoted by a line connecting the two use cases with an open arrowhead pointing towards the parent use case.

Extending a use case is like having a base model vehicle that has some standard features. By extending this base model to a 'deluxe' model, we can add or change functionality. The 'deluxe' model doesn't replace the base model; it's just an extended version.

AD

Applying 'Extends'

Use 'extends' when your system has a parent-child use case relationship, where the child adds functionalities without changing the parent or other child use cases. In e-commerce, for instance, Pay with Cash on Delivery could extend the Complete Purchase use case.

UML Use Case Diagrams: Tips
UML Use Case Diagrams: Tips
UML Use Case Diagram
UML Use Case Diagram
Student Attendance System | Creately
Student Attendance System | Creately
a diagram showing the different types of people connected to each other
a diagram showing the different types of people connected to each other
Shop System Use Case Diagram
Shop System Use Case Diagram
End-to-End UML: Use Case Diagram
End-to-End UML: Use Case Diagram
university use case diagram
university use case diagram
UML Use Case Diagram for Online Shopping
UML Use Case Diagram for Online Shopping
Usecase diagram
Usecase diagram
Verifying Use Cases, Data Flow Diagrams, Entity Relationship Diagrams, and State Diagrams via State Linkages
Verifying Use Cases, Data Flow Diagrams, Entity Relationship Diagrams, and State Diagrams via State Linkages
Library Management System | Creately
Library Management System | Creately
Sistema de cajeros (caso de uso) (es) | Creately
Sistema de cajeros (caso de uso) (es) | Creately
Online Examination System
Online Examination System
Order System Use Case | Creately
Order System Use Case | Creately

Here's an example: The Return Book use case extends the Purchase Book use case, adding functionality to reverse the original purchase process.

When not to 'Extend'

A common pitfall is misunderstanding 'extends' as a tool to alter the behavior of the parent use case. Remember, 'extends' is for adding function, not changing existing behavior. If you need to modify the parent use case, consider making them separate use cases with an 'include' relationship instead.

AD

For instance, 'Cancel Order' and 'Change Order Status' should ideally be separate use cases, each including the functionality they need, rather than 'Cancel Order' extending 'Change Order Status'.

In summary, understanding the 'includes' and 'extends' relationships in use case diagrams is vital for designing robust, flexible, and maintainable software systems. When used judiciously, these tools allow us to describe complex system behaviors effectively.

AD