Classes |
|
Methods |
|
|
|
Design Class |
Interaction |
|
|
||
Conceptual |
|
Contracts |
|
|
|
|
|
System
Sequence |
|
|
|
|
|
Expanded |
dice
game
throw
two dice,
if total = 7 you win, else you lose
description of a process in the domain
Use case |
Play a game |
Actors |
Player |
Description |
Player picks up and rolls the dice. The player wins if the total is 7. |
Concepts - entities recognised in the external world
player
die
dice game
show flow of messages between objects
software components, not external world concepts - but may model concepts
public class Die {
protected int faceValue;
public int getFaceValue() {
return faceValue();
}
public void roll() {
faceValue = (int) (Math.random() * 5 + 1)
}
}
public class Player {
protected String name;
public Player(String name) {
this.name = name;
}
public void play(Die die1, Die die2) {
die1.roll();
die2.roll();
}
public String getName() {
return name;
}
}
public class DiceGame {
protected Die die1, die2;
protected Player player;
public static void main(String[] argv) {
game = new DiceGame();
game.play();
if (game.isWon()) {
System.out.println("Won");
} else {
System.out.printl("Lost");
}
}
public DiceGame(String name) {
player = new Player(name);
die1 = new Die();
die2 = new Die();
}
public void play() {
player.play(die1, die2);
}
public boolean isWon() {
return (die1.getFaceValue() == die2.getFaceValue());
}
}
(chapter 6)
Narrative describing a sequence of events of an actor who uses a system to complete a process.
Not requirements, but illustrate and imply requirements.
Actors are external to the system
Use cases may be
concise description of process
Use case |
Buy Items |
Actors |
Customer, Cashier |
Type |
primary |
Description |
Customer arrives at checkout with items to purchase. Cashier records purchase items and collects payment. On completion, Customer leaves with items. |
more details
includes typical course of events
may include alternatives
Use case |
Buy Items with Cash |
Actors |
Customer (initiator), Cashier |
Purpose |
Capture a sale and its cash payment |
Overview |
Customer arrives at checkout with items to purchase. Cashier records purchase items and collects payment. On completion, Customer leaves with items. |
Type |
primary |
Cross References |
|
Actor Action |
System Response |
---|---|
Use case begins when a Customer arrives at POST checkout with items to buy. |
|
Cashier records identifier of each item. If several of same item, Cashier can enter quantity. |
Determines item price and adds item info to transaction. Description and price of current item presented. |
On completion of item entry, Cashier tells POST that item entry is complete. |
Calculates and presents the sale total. |
Cashier tells Customer the total. |
|
Customer gives Cashier at least enough cash. |
|
Cashier records the cash received amount. |
Shows change to be given to customer. Generates a receipt. |
Cashier deposits cash received and extracts balance. Cashier gives change and receipt to Customer. |
Logs the completed sale. |
Customer leaves with items purchased. |
|
Use case interaction with system
Must know system boundary
If boundary was store:
Actors are external to the system
Use case is about a process (buy items), not a step (write receipt)
Identifying use cases
identify actors
for each actor, identify processes
identify external events
relate events to actors
(Meyer, OOSC pp 738-740)
Use cases not appropriate for analysis in general, and finding classes in particular.
They focus on process rather than data abstraction.
They are appropriate as a validation tool - to inspect a proposed analysis model.
Use cases expressed in a way that does not imply an implementation.
examples
Essential |
Real |
---|---|
go to the shop |
ride your bike to the shop |
|
hang the clothes on the line |
wash the dishes |
|
|
send a letter to the customer saying that the goods have arrived |
Actor Action |
System Response |
---|---|
The customer identifies themselves. |
Presents options. |
Actor Action |
System Response |
---|---|
The customer inserts their card. |
Prompts for PIN. |
Enters PIN on keypad. |
Displays options menu. |
(chapter 7)
The first version of the software may not implement everything.
whole system is too complex
some parts less important
may want to get something working quickly
So, several versions, each with its own development cycle.
Requirements -> OOA -> OOD -> Implementation
OO paradigm supports incremental development |
rank use cases higher if they
have
significant impact on architecture
(add many classes or extra
layer such as persistence)
give significant insight into design with little effort
require risky, time-critical or complex functions
involve significant research or new and risky technology
represent core business
have impact on
"bottom line"
(more revenue, reduce costs)
Rank |
Use Case |
Justification |
---|---|---|
High |
Buy Items |
Scores on all except d) |
Medium |
Add new users Log in Refund items |
Affects security domain Affects security domain Core business, affects accounting |
Low |
Cash
out Start
up Shut down |
Minimal effect on architecture Depends on other use cases Minimal effect on architecture |
Need at least a simplified version to
get going.
eg create an empty store
Start up developed incrementally to satisfy other use cases as they are included.
Requirements -> OOA -> OOD -> Implementation