UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory UML Weekend Crash Course™ - To Parent Directory

crnarupa.singidunum.ac.rs
from crnarupa.singidunum.ac.rs More from this publisher
01.01.2015 Views

Session 7—Building the Use Case Narrative 71 value between 1 and 10, the second must be an integer greater than 100, and the character string can only be 30 characters in length. Without publishing these pre-conditions, anyone who wants to use your Use Case is forced into relying on trial and error to find the correct set of values. Tip Notice how rapidly we bring precision to the model from the simple beginnings of the Use Case diagram. You’ll find the analysis process akin to pulling a thread on an old sweater. If you keep pulling, eventually you’ll unravel the whole complex problem (while your mother yells at you for destroying a perfectly good sweater). Using simple checklists to remind you of the questions to ask can expedite the process and build a successful pattern of thought for problem solving. As you gain experience, modify the list of questions and tasks to improve the process and to make it your own. The goal is not to become a disciple of a particular technique, but to find a technique that works for you. Use Case initiation A Use Case has to start somehow, but how Some Use Cases start because an actor says, “Start.” For example, you can select an option on a menu. The action tells the system to open the application. Time can also trigger a Use Case. Most software shops have scheduling software that kicks off programs at a preset time. Other Use Cases are implemented as objects themselves that watch for a point in time. A Use Case may be triggered by a system event like an error condition, a lost connection, or a signal from a device. Use Case initiation provides a place to think through all the possible triggers that could launch the Use Case. This is critical when you start thinking about reusing Use Cases. If five actors and/or Use Cases plan on using the same Use Case, then you need to know how each user plans to kick it off. If each has different expectations, then you could be creating a problem. Multiple triggering mechanisms lead to high coupling and low independence. In other words, every time you change one of the triggers, you need to change the corresponding Use Case and make certain that you haven’t created problems with the other triggering mechanisms. More triggers mean more complicated and costly maintenance. Dialog The dialog refers to a step-by-step description of the conversation between the Use Case (the system) and the user (an actor or another Use Case). Very often, it is helpful to model this sequence of events using an Activity diagram just as you might model a procedure for communication between two business units. For example, you want to withdraw money, so you access the ATM at your local bank. The following dialog ensues: You get past the security check Use Case, and you’re presented with a menu of options. You choose “Withdraw.” The system immediately asks you which account you want to withdraw the money from.

72 Saturday Morning You reply that you want to withdraw from your primary checking account. The system then asks you how much you want to withdraw. You say that you want $47. The system gives you a nasty error message saying it can’t handle that number (because it’s not a multiple of 20) and you need to try again. Then you say you want $4,700. The system again complains that you can’t take that much money out in a 48-hour period. “Okay, okay! Give me $100,” you tell the system. Now the system is happy and it gives you the money and a receipt. When goals remain separate from implementation, you can evolve systems whose interface designs remain stable while their implementations take advantage of ever-improving user interface technologies. This conversation could just as easily have happened with any manufacturer’s ATM even if it held different cash denominations (10’s versus 20’s), connected directly to a bank, or connected via a nationwide network. Also, you begin to see that some of the steps don’t necessarily have to happen in the sequence presented here. The goal of the dialog is to uncover just what really needs to happen and what variations could be valid. Even ATM interface designs vary. Have you ever seen an ATM designed for blind people It performs the exact same conversation but with a different user interface. My home banking software accomplishes essentially the same function, too, but with still a different design for the interface. The system asks all the questions at once and I provide all the answers at once. Same design, different interface. Use Case termination Although there is usually only one triggering event to start a Use Case, there are often many ways to end one. You can pretty much count on some kind of normal termination where everything goes as planned and you get the result you anticipated. But things do go wrong. This could mean shutting down the Use Case with an error message, rolling back a transaction, or simply canceling. Each termination mechanism has to be addressed in the dialog. The list of termination options is a bit redundant with the dialog, but just as was the case with pre-conditions, this redundancy provides some good checks and balances. Post-conditions Post-conditions describe a state of the system that must be true when the Use Case ends. You may never know what comes after the Use Case terminates, so you must guarantee that the system is in a stable state when it does end. In fact, some people use the term guarantee for just this reason. You guarantee certain things to be true when this Use Case completes its job. You might, for instance, guarantee to give the user a receipt at the end of the transaction, whether it succeeded or failed. You might promise to notify the user of the result of an attempted save to the database.

Session 7—Building the Use Case Narrative 71<br />

value between 1 and 10, the second must be an integer greater than 100, and the character<br />

string can only be 30 characters in length. Without publishing these pre-conditions, anyone<br />

who wants to use your Use Case is forced into relying on trial and error to find the correct<br />

set of values.<br />

Tip<br />

Notice how rapidly we bring precision to the model from the simple beginnings<br />

of the Use Case diagram. You’ll find the analysis process akin to pulling a<br />

thread on an old sweater. If you keep pulling, eventually you’ll unravel the<br />

whole complex problem (while your mother yells at you for destroying a perfectly<br />

good sweater). Using simple checklists to remind you of the questions<br />

to ask can expedite the process and build a successful pattern of thought for<br />

problem solving. As you gain experience, modify the list of questions and tasks<br />

to improve the process and to make it your own.<br />

The goal is not to become a disciple of a particular technique, but to find a<br />

technique that works for you.<br />

Use Case initiation<br />

A Use Case has to start somehow, but how Some Use Cases start because an actor says,<br />

“Start.” For example, you can select an option on a menu. The action tells the system to<br />

open the application. Time can also trigger a Use Case. Most software shops have scheduling<br />

software that kicks off programs at a preset time. Other Use Cases are implemented as objects<br />

themselves that watch for a point in time. A Use Case may be triggered by a system event<br />

like an error condition, a lost connection, or a signal from a device.<br />

Use Case initiation provides a place to think through all the possible triggers that could<br />

launch the Use Case. This is critical when you start thinking about reusing Use Cases. If five<br />

actors and/or Use Cases plan on using the same Use Case, then you need to know how each<br />

user plans to kick it off. If each has different expectations, then you could be creating a<br />

problem. Multiple triggering mechanisms lead to high coupling and low independence. In<br />

other words, every time you change one of the triggers, you need to change the corresponding<br />

Use Case and make certain that you haven’t created problems with the other triggering<br />

mechanisms. More triggers mean more complicated and costly maintenance.<br />

Dialog<br />

The dialog refers to a step-by-step description of the conversation between the Use Case<br />

(the system) and the user (an actor or another Use Case). Very often, it is helpful to model<br />

this sequence of events using an Activity diagram just as you might model a procedure for<br />

communication between two business units.<br />

For example, you want to withdraw money, so you access the ATM at your local bank. The<br />

following dialog ensues:<br />

You get past the security check Use Case, and you’re presented with a menu of options.<br />

You choose “Withdraw.”<br />

The system immediately asks you which account you want to withdraw the money<br />

from.

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

Saved successfully!

Ooh no, something went wrong!