Derive Requirements from Use Cases using ChatGPT
In the first attempt to define what a system shall do, simple yet powerful use case definitions are often used.
If you are unsure what a use case is, let's ask ChatGPT.
A use case definition is a description of a specific goal or task that a user or system aims to achieve. It outlines the steps and actions that are necessary to complete the task, as well as any specific conditions or constraints that must be met. Use case definitions are often used in software development to help define the requirements and functionality of a system. They can also be used in other fields, such as business or project management, to describe how a particular process or workflow should be performed.
A use case is composed of the following:
title: a meaningful name of the use case
primary actor: a definition who uses the system
goal: a description of what the actor wants to achieve
preconditions: a set of conditions that must be fulfilled before the actor can perform the use case
main flow: a set of performed activities during the use case execution
postcondition: a set of conditions that are fulfilled after the use case is executed
special cases: a list of situations that could interrupt the main flow that need specific handling
Sounds still abstract? Let's look into an example:
Title: Place an Order
Primary Actor: Customer
Goal: The customer will be able to place an order for a product on the website.
Preconditions:
The customer has an account on the website
The customer has added items to their cart
The customer has selected a shipping address
Trigger: The customer clicks the "Place Order" button on the shopping cart page.
Main Flow:
The system displays an order summary page, including the customer's shipping address and a list of the items in the cart.
The customer reviews the order and clicks the "Submit Order" button.
The system charges the customer's credit card and displays a confirmation page.
The system sends a confirmation email to the customer.
Postcondition:
- The customer's order is saved in the system, and the items are removed from the cart.
Special Cases:
If the customer's credit card is declined, the system will display an error message and ask the customer to enter a different form of payment.
If the customer's account does not have a shipping address, the system will prompt the customer to add one before proceeding.
Even if a use case definition sounds quite precise, a lot of details are left out. These details can be further defined in a set of functions as I described in Structure Requirements in Functions.
NOTE: I asked ChatGPT to generate a plantUML definition for the use case to be able to easily visualize it. Unfortunately, ChatGPT is currently not able to generate plantUML.
With the use case definition at hand, we can request a list of functions from ChatGPT.
Display order summary page - This function would be responsible for displaying the customer's shipping address and a list of the items in their cart when the "Place Order" button is clicked.
Submit order - This function would handle the customer's submission of the order and charge the customer's credit card.
Display confirmation page - This function would display a confirmation page to the customer after the order has been placed.
Send confirmation email - This function would send a confirmation email to the customer with the details of their order.
Check account details - This function would check if the customer has an account, shipping address and if credit card is valid.
Handle error - This function would handle the error cases when credit card is declined or shipping address is not available.
Those functions are building blocks that combined in the right fulfill the use case. The goal should be to iterate over the functions and make them more generic (where appropriate) to reuse them to support more use cases.
To be ready for implementation, the functions itself need to be refined into requirements to be precise enough to give it to someone for implementation.
The 'Check Account Details' function shall check if the customer has an account on the website.
The 'Check Account Details' function shall check if the customer has selected a shipping address.
The 'Check Account Details' function shall check if the customer's credit card is valid.
The 'Check Account Details' function shall check if the customer's account is active and not blocked.
The 'Check Account Details' function shall check if the customer's account has enough balance to complete the transaction.
The 'Check Account Details' function shall validate the customer's shipping address against the valid address format.
The 'Check Account Details' function shall check if the customer's credit card is not expired.
The 'Check Account Details' function shall check if the customer's credit card is not reported as stolen or lost.
The 'Check Account Details' function shall check if the customer's credit card is not exceeding the maximum limit.
The 'Check Account Details' function shall check if the customer has not reached the maximum number of transaction allowed per day.
To sum up, the time to create a concrete list of requirements from an initial use case definition can be drastically reduced with the help of ChatGPT.