use cases

© Pearson Education 2005
Chapter 10 (RASD 2/e)
Topics
MACIASZEK, L.A. (2005):
Requirements Analysis and System Design, 2nd ed.
Addison Wesley, Harlow England, 504p.
„
Use case modeling
ISBN 0 321 20464 6
„
Activity modeling
„
Class modeling
„
Interaction modeling
„
Statechart modeling
„
Implementation models
„
Object collaboration design
„
Window navigation design
„
Database design
Chapter 10
Tutorial-style Review and Reinforcement
© Pearson Education Limited 2005
© Pearson Education 2005
Tutorial – OnLine Shopping
„
„
„
„
„
„
Buying computers over Internet using the manufacturer’s web
page.
Computers classified into servers, desktops and portables.
Customer can select standard configuration or can configure
his/her own configuration.
To place order, the customer must fill out the shipment and
payment information.
The system sends a confirmation e-mail message to the
customer with details of the order.
Customer can check the order status online at any time.
Moreover, the system needs to
•
•
•
•
Consider the following requirements:
3. The customer may choose to order a computer
online or may request that the salesperson contact
him/her to explain order details, negotiate the price,
etc. before the order is actually placed.
7. The warehouse obtains the invoice from the
salesperson and ships the computer to the
customer.
verify the customer’s credentials and payment method,
request the ordered configuration from the warehouse,
print an invoice, and
request the warehouse to ship the computer to the customer.
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
2
Use case modeling - actors
• For each new configuration, the system can calculate price.
„
Chapter 10 (Maciaszek - RASD 2/e)
Customer
3
© Pearson Education 2005
Salesperson
Chapter 10 (Maciaszek - RASD 2/e)
Warehouse
4
Use case modeling – use cases
Consider the following requirements:
3. The customer may choose to order a computer
online or may request that the salesperson contact
him/her to explain order details, negotiate the price,
etc. before the order is actually placed.
7. The warehouse obtains the invoice from the
salesperson and ships the computer to the
customer.
Display Standard
Computer Configuration
Build Computer
Configuration
Order Configured
Computer
Verify and Accept
Customer Payment
Request
Salesperson Contact
Chapter 10 (Maciaszek - RASD 2/e)
MACIASZEK (2005): Req Analysis & Syst Design
Print Invoice
Print Invoice
Warehouse
© Pearson Education 2005
<<extend>>
Request
Salesperson Contact
Display
Order Status
Orde r Co nfigured
Co mp uter
Customer
Use case
diagram
5
© Pearson Education 2005
Inform Warehouse
about Order
Salesperson
Chapter 10 (Maciaszek - RASD 2/e)
6
1
© Pearson Education 2005
Chapter 10 (RASD 2/e)
Documenting use cases
Activity modeling - actions
Order Configured
Computer
Use case
Order configured computer
Brief
description
This use case allows a Customer to enter a purchase order.
This includes providing a shipment and invoice address as well
as payment details.
Actors
Customer
Preconditions
Customer points Internet browser to the computer
manufacturer’s order entry web page. The page displays the
details of a configured computer together with its price.
Main flow
The use case begins when the Customer decides to order ...
The system requests that the Customer enters ...
The Customer chooses the Purchase function ...
The system assigns a unique order number ...
The system e-mails the order number and ...
Alternative
flows
The Customer activates the Purchase function before ...
The Customer chooses the Reset function to revert to ...
Postconditions If the use case was successful, the purchase order is recorded
in the system’s database. Otherwise, the system’s state is
unchanged.
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
Activity diagram
[ timeout ]
Get Ord er
Request
Display Purchase
Form
[ incomplete ]
4
The system assigns a unique order number
and a customer account number to the
purchase order and it stores the order
information in the database.
Store Order
5
The system e-mails to the Customer the
order number and the customer number,
together with all order details, as the
confirmation of the order’s acceptance.
Email Order Details
Store Order
© Pearson Education 2005
Email Order
Details
Chapter 10 (Maciaszek - RASD 2/e)
8
6
The details of the transaction, including an order Order, Customer,
(OrderStatus)
number and a customer account number, are
emailed to the customer, so that the customer
can check the status of the order online.
7
The warehouse obtains the invoice from the
salesperson and ships the computer to the
customer.
Orde r
Custome r
Invoice
Invoice, (Salesperson),
(Shipment),Computer,
Customer
Computer
S tore Order
Orde rS tatus
[ OK ]
Get Purchase
Details
Email Order
Details
© Pearson Education 2005
Get Purchase Details
Class modeling – classes
Order Configured
Computer
Display Current
Computer
The Customer chooses the Purchase (or
similarly named) function to send the order
to the manufacturer.
Get Purchase
Details
7
Order Configured
Computer
3
Chapter 10 (Maciaszek - RASD 2/e)
9
Class modeling – attributes
Shipment
?
?
„
Do we need the Shipment class if we know that the shipment is the
warehouse responsibility and it is therefore out of the scope?
„
Is OrderStatus a class or an attribute of Order?
„
Is Salesperson a class or an attribute of Order and Invoice?
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
10
Class modeling – associations
Computer
Customer
Customer
customerName : String
customerAddress : String
phoneNumber : String
emailAddress : String
Order
o rd erNum be r : String
o rd erDate : Date
ship Ad dress : String
o rd erTo tal : float
o rd erSta tus : String
sa le spe rso nName : String
1
Order
1
Invoice
invoiceNumber : String
invoiceDate : Date
invoiceTotal : float
© Pearson Education 2005
MACIASZEK (2005): Req Analysis & Syst Design
1
0..n
1..n
Computer
computerName : String
standardPrice : float
Chapter 10 (Maciaszek - RASD 2/e)
ConfigurationItem
0..n
1
Payment
11
© Pearson Education 2005
0..1
ConfiguredComputer
Invoice
Chapter 10 (Maciaszek - RASD 2/e)
12
2
© Pearson Education 2005
Chapter 10 (RASD 2/e)
Class modeling – aggregations
Class diagram
Customer
custo me rName : String
custo me rAddress : String
p hone Number : String
e ma ilA dd ress : String
Computer
Customer
ConfigurationItem
ite mType : S tring
ite mDe scr : S tring
1..n
1..1
1
1..n
0..n
ConfigurationItem
0..n
Order
1
1..n
0..n
1
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
13
Sequence diagram
:
P Custom Config ura tion
: EComputer
Computer
computerName : String
1..n
1..1
Invoice
Payment
0..n
Payment
paymentMethod : String
dateReceived : Date
amountReceived : float
ConfiguredComputer
1
1..1
1..1
1..n
0..1
0..1
Order
orderNumber : String
orderDate : Date
shipAddress : String
orderTotal : float
orderStatus : String
salespersonName : String
Invoice
invoiceNumber : String
invoiceDate : Date
invoiceTotal : float
© Pearson Education 2005
ConfiguredComputer
configuredPrice : float
Chapter 10 (Maciaszek - RASD 2/e)
Collaboration diagram
Display Current
Configuration
S tand ardComputer
standardPrice : float
14
Display Current
Configuration
: EConfigurationItem
1.1.1. getComputerName()
1.1.3. getPrice()
1. submit()
1. submit()
1.1. getCurrentConf()
1.1. getCurrentConf()
1.1.1. getComputerName()
: PCustomConfiguration
: EComputer
1.1.2. getItemDescr()
1.1.3. getPrice()
1.2. new(currentConf)
1.2. new(currentConf)
:
PConfigurationSummary
1.2.1. display()
1.1.2. getItemDescr()
1.2.1. display()
: PConfigurationSummary
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
15
Class methods
PCustomConfiguration
submit()
© Pearson Education 2005
: EConfigurationItem
Chapter 10 (Maciaszek - RASD 2/e)
States and transitions
16
E Invoice
E Config ura tionItem
itemType : String
itemDescr : String
getItemDescr()
Unpaid
partial payment
Partly Paid
1 ..n
ECom puter
PConfigurationSummary
final payment
computerName : String
PConfigurationSummary(currentConf)
display()
final payment
getCurrentConf()
getComputerName()
getPrice()
Fully Paid
EStandardComputer
co nfigured Price : floa t
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
MACIASZEK (2005): Req Analysis & Syst Design
E ConfiguredComputer
standardPrice : float
17
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
18
3
© Pearson Education 2005
Chapter 10 (RASD 2/e)
EOrder
Statechart diagram
Subsystems
Pending
<<sub syste m>>
p re senta tion
stock not available
New Order
Back Order
stock available[ ship date in future ]
<<sub syste m>>
co ntro l
Future Order
stock available[ ship date in future ]
[ canceled ]
Cinterface
Minterface
<<sub syste m>>
entity
<<subsystem>>
mediator
<<subsystem>>
fo unda tion
stock available[ ship date now ] / configureComputer
Canceled
Ready to Ship
[ canceled ]
ship[ accepted ]
Einterface
Finterface
Filled
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
19
Packages
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
20
Packages
Einterface
<<sub syste m>>
p re senta tion
Cinte rfa ce
configuration view
order view
identity map
<<subsystem>>
entity
Finterface
<<subsystem>>
control
orders
Minterface
configuration
provider
c om puters
order monitor
<<subsystem>>
foundation
customers
crud
<<subsystem>>
mediator
data mapper
l az y l oa d
schema
unit of work
c onnection
Einterface
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
21
Components
Chapter 10 (Maciaszek - RASD 2/e)
22
Nodes – deployment diagram
Client
Browser
P ro ductDisp la y
ProductList
© Pearson Education 2005
Web Server
HTTP
Configuration
JDBC, SQLJ
Purchase
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
MACIASZEK (2005): Req Analysis & Syst Design
Database
Server
OrderTracking
23
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
24
4
© Pearson Education 2005
Chapter 10 (RASD 2/e)
Prototype for a web page
Behavioral collaboration
<<screen>>
<<screen>>
Client Logon Order Status
CStatusMonitor MDataMapper
FReader
EIdentityMap EOrder
1: display( clientAccNum, orderNum )
2: getOrderStatus( orderNum )
3: retrieveOrderStatus( orderNum )
4: query( sqlString )
5: display()
6: findOrder( orderNum )
7: update( orderStatus, shipAddress )
8: setClean()
9: new( orderStatusData )
EOrderStatus
10: setClean()
11: register( orderStatus )
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
25
© Pearson Education 2005
Structural collaboration
PClientLogon
Chapter 10 (Maciaszek - RASD 2/e)
User experience (UX) elements
POrderStatus
<<screen>>
Computer Order *
+display( clientAccNum, orderNum ) : void
-display() : void
EIdentityMap
CStatusMonitor
+getOrderStatus( orderNum ) : java.util.Collection
+findOrder( orderNum ) : EOrder
+register( orderStatus ) : java.lang.String
1
MDataMapper
FReader
+retrieveOrderStatus( orderNum ) : java.util.Collection
+query( sqlString ) : java.sql.ResultSet
EOrder
-theOrder
-setClean() : void
+update( orderStatus, shipAddress ) : void
© Pearson Education 2005
26
0..*
0..1
*
<<compartment>>
<<screen>>
<<compartment>>
Order Entry
Command Button
Order Confirmation
Database Exception
EOrderStatus
-theOrderStatus
1
2
<<input form>>
+EOrderStatus( orderStatusData )
-setClean() : void
Chapter 10 (Maciaszek - RASD 2/e)
27
<<input form>>
Incomplete Order Entry
© Pearson Education 2005
Behavioral UX collaboration
Chapter 10 (Maciaszek - RASD 2/e)
28
Structural UX collaboration
<<screen>>
Computer Order *
1
+$navigate to()
2
<<input form>>
Order Entry
+contact details
+explanations
+invoice address
+order summary
+payment method
+salesperson name
+shipment items
+title
Chapter 10 (Maciaszek - RASD 2/e)
MACIASZEK (2005): Req Analysis & Syst Design
29
<<screen>>
Command Button
+cancel
+submit
+press cancel()
+press submit()
+$display explanations()
+$display order summary()
+$navigate to()
+enter contact details()
+enter invoice address()
+enter payment method()
+enter salesperson name()
+enter shipment items()
© Pearson Education 2005
0..1
<<compartment>>
© Pearson Education 2005
Order
Confirmation
*
<<compartment>>
Database
Exception
+confirmation message
+exception message
+$navigate to()
+$navigate to()
<<input form>>
Incomplete
Order Entry
+invitation to complete
+missing items
+$navigate to()
Chapter 10 (Maciaszek - RASD 2/e)
30
5
© Pearson Education 2005
Chapter 10 (RASD 2/e)
Object-relational mapping
Referential integrity design
StandardComputer
ConfiguredComputer
StandardComputer
ConfiguredComputer
computer_id
CHAR(15)
<pk> not null
computer_name VARCHAR2(50)
not null
standard_price NUMBER
not null
CHAR(15)
<pk> not null
computer_id
computer_name VARCHAR2(100)
not null
configured_price NUMBER
not null
com puter_id
CHAR(15)
<pk> not null
com puter_name VARCHAR2(50)
not null
standard_price NUMBER
not null
computer_id
CHAR(15)
<pk> not null
computer_name VARCHAR2(100)
not null
configured_price NUMBER
not null
Upd(R); Del(C);cpa
0..*
Upd(R); Del(C);cpa
ConfItemToConfComp
ConfItemToStdComp
ConfItemToConfComp
computer_id CHAR(15) <pk,fk1> not null
item_id
INTEGER <pk,fk2> not null
computer_id CHAR(15) <pk,fk1> not null
item_id
INTEGER <pk,fk2> not null
computer_id CHAR(15) <pk,fk1> not null
item_id
INTEGER <pk,fk2> not null
computer_id = computer_id
0..*
computer_id = computer_id
ConfItemToStdComp
computer_id CHAR(15) <pk,fk1> not null
item_id
INTEGER <pk,fk2> not null
0..*
0..*
0..*
item_id = item_id
0..*
0..*
item_id = item_id
Upd(R); Del(C);cpa
Upd(R); Del(C)
ConfigurationItem
ConfigurationItem
item_id
INTEGER
<pk> not null
item_type
VARCHAR2(60)
not null
item_descr VARCHAR(200)
not null
INTEGER
<pk> not null
item_id
item_type
VARCHAR2(60)
not null
item_descr VARCHAR(200)
not null
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
31
Referential integrity design
Payment
payment_id
payment_method
date_received
amount_received
0..*
CHAR(12)
<pk> not null
VARCHAR(40)
not null
DEC
not null
NUMBER(8,2)
not null
Invoice
Upd(R); Del(N)
1..1
© Pearson Education 2005
32
„
use case modeling
„
activity modeling
„
class modeling
„
interaction modeling
„
statechart modeling
„
implementation models
„
object collaboration design
„
window navigation design
„
database design
1..1
Order
order_number
customer_number
status_id
payment_id
invoice_number
order_date
ship_address
order_total
salesperson_name
Chapter 10 (Maciaszek - RASD 2/e)
Summary
invoice_number CHAR(12) <pk> not null
invoice_date
DATE
not null
invoice_total
NUMBER
not null
Upd(R); Del(R)
© Pearson Education 2005
CHAR(12)
CHAR(15)
CHAR(2)
CHAR(12)
CHAR(12)
DATE
VARCHAR2(120)
NUMBER
VARCHAR2(30)
Chapter 10 (Maciaszek - RASD 2/e)
MACIASZEK (2005): Req Analysis & Syst Design
<pk>
<fk1>
<fk2>
<fk3>
<fk4>
not null
not null
not null
not null
null
not null
null
not null
null
33
© Pearson Education 2005
Chapter 10 (Maciaszek - RASD 2/e)
34
6