21.08.2013 Views

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.7 ● Use cases<br />

4.7 Use cases 45<br />

One widely used approach to documenting requirements is “use cases”. These are<br />

textual descriptions which can be augmented by UML use case diagrams. Use cases<br />

take the point of view of the user or users of the system. A user who is carrying out<br />

a particular role is called an actor. A use case is a task that an actor needs the system<br />

to carry out.<br />

For example, in the ATM system (Appendix A), one of the things that a user does is<br />

withdraw cash. This is a use case. As part of withdrawing cash, the user will have to carry<br />

out subtasks, such as offering up their card and entering a PIN, but these smaller tasks<br />

are not use cases. It is the overall user task that constitutes a use case.<br />

A use case both specifies what the user does and what the system does, but says nothing<br />

about how the system per<strong>for</strong>ms its tasks. In the ATM system, the use case <strong>for</strong> withdrawing<br />

cash is:<br />

withdraw cash. The user offers up their card. The system prompts <strong>for</strong> the PIN. The user<br />

enters the PIN. The system checks the PIN. If the card and PIN are valid, the system<br />

prompts the user <strong>for</strong> their choice of function. The user selects dispense cash. The user<br />

prompts <strong>for</strong> the amount. The user enters the amount. The system ejects the card. When<br />

the user has withdrawn the card, the system dispenses the cash.<br />

We see that the user’s task requires a whole number of detailed steps. Sometimes the<br />

user’s objective is not achieved, <strong>for</strong> example, if the PIN is wrong. However, the overall<br />

name of the use case describes what normally happens.<br />

Other use cases <strong>for</strong> the ATM are check balance and transfer money.<br />

SELF-TEST QUESTION<br />

4.2 Write a use case <strong>for</strong> checking a balance.<br />

You will see that sometimes different use cases have parts in common. This is no<br />

problem.<br />

In the above example, and in most cases, the actor is a person, but an actor can<br />

be anything that interacts with the system. This could be, <strong>for</strong> example, another software<br />

system or another computer communicating across the internet. For example,<br />

in a web server (program), the actor is a web browser program running on another<br />

computer.<br />

It is sometimes difficult to identify distinct use cases. In the ATM, <strong>for</strong> example, is<br />

entering and validating the PIN a use case? The answer is no because it is not a useful<br />

function from the user’s point of view, whereas withdrawing cash is. Suppose a person

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!