Use Case Diagrams and examples in Software Engineering
Let’s see the Use Case Diagrams and examples in Software Engineering.
What is the use case?
A use case is an event or action with reference to the user/actor of the event/actions that should be performed through the software.
What is the use case diagram?
When we represent the use case and their interaction with actors/users through the UML(Unified modeling language), then this kind of modeling is use case diagram.
Relationships among use cases:
Extend: There is an optional relationship among use cases.
Include: There is a compulsory relationship among use cases.
Inheritance: Some variables, functions or some other things are inherited from one use case to another use case.
Example 1:
Case Study of Use Case Diagrams
You need to develop a social networking website with the following functionalities; First of all, the user should create his account. After that, the user can log in to the system and can change his profile picture. The Registered user should also be able to search for a friend. After searching a friend user can add friend.
Solution:
Figure 1 represents the actions of a social website.
Use case: Register, Login
The user should register. After register user can log in to the system. So it means that register is a must to get a login(included). The direction of the arrow represents that “register” is compulsory before “login”.
Use case: Login
once the user creates an account, now the user can log in every time without “signup”. So we also draw a direct arrow from the user to login(extend).
Use cases: Login, Upload profile picture
When the user gets a login, now there is a choice for the user, that user can upload a profile picture or not. It totally depends on the choice of the user(extend).
Use cases: Login, search friend
When the user gets a login, now there is a choice for the user, that the user can search a friend or not(extend).
Use cases: Search friend, Add friend
When the user gets a login, now there is a choice for the user, that the user can search a friend or not(extend). When a user searches a friend, then there is an option that the user adds a friend or not(extend). But when a user adds friend then it must that user should first search the friend(included).
Example 2:
Case Study 2 of Use Case Diagrams
You need to develop a web-based application with the following functionalities; Users can buy products online by placing the online order. The user can pay the bill by credit card or through Paypal.
This diagram represents inheritance among use cases. Place an order is the parent use case and pay through PayPal and pay through a credit card are child use cases. It means that some of the variables, functions are something else is inherited from parent to child.
- Place an order is the parent use case.
- Pay through Paypal is a child use case
- Pay through credit card is a child use case
Variables, functional and all kinds of data etc, that is set as protected, can be accessed from parent to child use case. For example, here anything can be inherited from place order use case to pay through pay and pay through credit card.
Example 3:
This diagram represents inheritance among use cases. authentication is the parent use case and authentication by finger authentication by info are child use cases. It means that some of the variables, functions are something else is inherited from parent to child.
Template for an explanation of the diagram
Base Use case | Related Use case | Relationship of Base Use case with Related | Meaning |
authentication | Authentication by fingerprint | “authentication” is the parent of “Authentication by fingerprint” | “authentication” will share the details with “Authentication by fingerprint”. |
authentication | Authentication by info | “authentication” is the parent of “Authentication by info” | “authentication” will share the details with “Authentication by info”. |
- Authentication is the parent use case.
- Authentication by fingerprints is a child use case
- Authentication by info is a child use case
Variables, functional and all kinds of data, etc that are set as protected, can be accessed from parent to child use case. For example, here anything can be inherited from authentication use case to authentication by fingerprints and authentication info.
Case Study of Use case diagram
Suppose you need to make a software in which when the user confirms order and confirmation need the confirmation depends upon the product selection, calculation of price with tax and payment. Payment can be through PayPal or credit card.
Draw the use case diagram.
Solution
First step: Identify the requirements and put them in an oval shape.
Second step: Identify the users
Third step: Identify the relationships include, extend and generalization(parent/child).
Fourth step: Draw the Boundary
Fifth step: Connect the actor/user with the use case.
For example, in this case study following are the functional requirements;
- The user can confirm the order
- The order confirmation must be followed by the selection of the product.
- The order confirmation must be followed by the Calculate price with tax.
- The order confirmation must be followed by the Payment.
- The payment can be done through PayPal or credit card.
Base Use case | Related Use case | Relationship of Base Use case with Related | Meaning |
Confirm order | Selection of product | “Selection of product” must be included with “Confirm order” | “Confirm order” will complete only if “Selection of product” is done. |
Confirm order | Calculate price with tax | “Calculate price with tax” must be included with “Confirm order” | “Confirm order” will complete only if “Calculate price with tax” is done. |
Confirm order | payment | “payment” must be included with “Confirm order” | “Confirm order” will complete only if “payment” is done. |
Confirm order | Print slip | “Print slip” is extended with “Confirm order” | “Confirm order” can complete with or without “Print slip” is done. |
payment | Payment through PayPal | “payment” is the parent of “Payment through PayPal” | “payment ” will share the details with “Payment through PayPal”. |
payment | Payment through credit card | “payment” is the parent of “Payment through credit card.” | “payment ” will share the details with “Payment through credit card”. |
Advantages of use case diagrams
There are many benefits to use cases. Some of the advantages are mentioned below;
- Use case helps us to draw and to understand the functional requirements of a system.
- The use case can evolve at each iteration. For example, it can evolve from capturing requirements to development guidelines, and similarly to a test case. Finally, use cases can evolve into user documentation.
- Use cases are traceable.
- Use cases can be used as the basis for the effort, scheduling, estimation, and validation.
- Use cases are easily understandable by technical and non-technical users. Use cases work as the understanding bridge between the software team and end-users or customers of the software.
- Use cases can improve system robustness.
Frequently Asked Questions (FAQ)
Class diagrams and use case diagrams illustrate systems based on what concept?
Class diagrams and use case diagrams are used to illustrate systems based on the concept of UML (Unified Modeling Language).
What is the difference between include, base use case and included use case?
- The included use case is mandatory and not optional.
- The base use case is incomplete without the included use case
For example, in the figure confirm the order is the base use case and payment is included use case. It means that system will confirm the order if and only if the payment process will complete.
Use Case Diagram Exercise
You can click here to exercise the use case diagrams.