©Vladimir Levin

Use Cases

Use cases are used in the Rational Unified Process (RUP for short) as the primary means of driving software application development. The aim of a use-case driven approach is to focus attention on the customers and their interaction with the software. This focus on user interaction has become mainstream in modern software development. Other popular methodologies, such as Extreme Programming (XP for short) also adopt a customer-centered approach. In XP, requirements are captured as Stories. The exact format of a story is up to the development team. It can be written as a few sentences on a 3-5 card; but it can also take the shape of a simple use case.

A use case defines a relatively small unit of interaction, usually between a user and a computer system (in some rare cases it can represent the interaction between two systems). In a system with different kinds of users, each kind of user is defined as an Actor. If the system is a vending machine, one may for example define a couple of Actors: The buyer, and the manager. It is likely that most of the software for a vending machine focuses on the buyer, but some features of the system will represent management functions such as configuring the slots inside the vending machine by assigning an id and a price to each slot.

There are a variety of templates available for building use cases, some more complicated than others. A simple way to define a use case, using the vending machine example, is as follows

Use Case: Purchase Items
Basic Course
  1. The buyer puts money into the machine. The machine adds up the amount with each insertion and and displays it to the buyer.
  2. The buyer enters in the code for the item he/she wishes to purchase
  3. The machine dispenses the item
  4. The user may not obtain change or purchase another item.
Alternate Courses
  • In 2 of the basic course, if the user enters in an invalid code, or has not entered enoug money, the machine displays an error.
  • The user can press 'cancel' at any time before a purchase has been completed to get his/her money back.

Use cases can become quite complex, with pre-conditions, post-conditions, etc. However, use cases lost their value if they become so complex as to become un-intelligible,

Use cases can be represented using diagrams to illustrate the high-level behaviour of the application.

Groups of use cases can be organized into packages.

XP Stories

User Stories in XP are very similar to use cases. The primary difference is that stories must be quite simple and straightforward. In RUP, it is possible for use cases to become quite intricate, whereas in XP this is actively discouraged. One can certainly use the simple use case style above for XP stories. Stories can also be written on 3-5 cards or listed as rows in a spreadsheet or issue-tracking application (e.g. Bugzilla).The emphasis on XP is to use a low-ceremony approach, but otherwise to use whatever technology seems appropriate for the given project.