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.
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.
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).
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.
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.
- 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.
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.
Advantages of use case diagrams
There are many benefits of use cases. Some of the advantages are mentioned below;
- Use case helps us to draw and to understand the functional requirements of a system.
- 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 be 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 works as the understanding bridge between 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).
Use Case Diagram Excercise
You can click here to exercise the use case diagrams.