Академический Документы
Профессиональный Документы
Культура Документы
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
Design
Assigning responsibilities to object
Taking illities (maintainability, reusability, etc.) and
portability into account
Devising mechanisms
OO Analysis Activities
Use case analysis
Mostly focused on writing text - one overview context diagram is
often enough
Use cases are just a part of functional requirements (only the
interactive ones)
Behavioral analysis
Creating activity diagrams and sequence diagrams to capture use
case details
Activity diagrams for business workflow
Sequence diagrams for reactive behavior (also with timing)
Possibly creating state charts to capture external reactive behavior
of the system and other domain objects
5
OO Design Activities
Creating interaction diagrams and distributing
responsibilities
Devising mechanisms and introducing design objects
Creating sequence diagrams
Creating collaboration diagrams
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
Vending Machine
Customer
Use Case 1
(Buy a drink)
Vending Machine
Customer
Use Case 1
(Buy a drink)
Use Case 2
(Restock)
Agent
9
Fully dressed
Formal sections
Preconditions
Main scenario
Exception list
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
Noun analysis
Consider a simplified vending machine, which is used to dispense soft
drinks. The vending machine consists of a coin slot for inserting coins, a
return tray for returning the customer's money and three buttons used
to select Pepsi (tm), Coke (tm) or Dr. Pepper (tm). If the customer inserts
coins and does not press a button within one minute, the coins will be
returned automatically (no coin-return lever). If the customer selects a
beverage which is out-of-stock (none left), the coins will also be returned.
This vending machine does not provide change - it is up to the customer to
insert only enough money to purchase a drink. If sufficient coins are
inserted and a button with available beverages is pressed, the appropriate
drink is dispensed, the corresponding button is illuminated for five
seconds, and the coin slot moves the coins to the general storage area (i.e.
the purchase has finished).
15
Contains
CoinSlot
amount
Contains
1
Customer
Pushes
Button
id
litUp
Vending
Machine
Shelf
1 0..*
Drink
Contains
1
Contains
3
Contains
ReturnTray
16
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
machine
insertMoney(x)
insertMoney(y)
push(z)
m:=checkAmount(x+y)
a:=checkAvailability(z)
[!a] return()
[m&a]
5 sec
dispenseDrink()
lightUp()
moveCoins()
lightDown()
18
VendingMachine
Insert money
Select drink
money
Sufficient
money?
no
yes
Dispense drink
drink
19
Ready
Push button Z [sufficient
money & drink Z in stock]
Dispensing
Entry/
dispense drink,
light up button,
take money
20
Coin slot
empty
Push button Z [sufficient
money & drink Z in stock]
Coin slot
has money
after (5 seconds)
Dispensing
Entry/
dispense drink,
light up button,
take money
21
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
Sequence Diagram
customer
coinSlot
button1
controller
shelfRel1
shelfSens1
insertMoney(x)
insertMoney(y)
push()
request(1)
close()
m:=checkAmount()
getTotal()
a:=checkAvailability()
isEmpty()
[!a] return()
[m&a]
lightUp()
release()
moveCoins()
5 sec
open()
lightDown()
23
Extension 2a
customer
coinSlot
button1
controller
insertMoney(x)
set(60)
insertMoney(y)
set(60)
timer
60 sec
checkTime()
checkTime()
timeOut()
return()
insertMoney(x)
set(60)
insertMoney(y)
set(60)
< 60 sec
push()
request(1)
close()
reset()
24
Collaboration Diagram
(Used to be collaboration diagram)
2: push()
button1
2.1: request(1)
timer1
1.1: set(60)
2.1.1.1: reset()
2a: timeOut()
coinSlot
1: insertMoney(x)
2.1.1: close()
2.1.2.1: getTotal()
2.1.4a [!a]: return()
2.1.7 [m&a]: moveCoins()
3.1.1: open()
shelfRel
controller
2.1.3.1: isEmpty()
self
2.1.2: m:=checkAmount()
2.1.6: set(5)
2.1.3: a:=checkAvailability()
3: timeOut()
shelfSens
timer2
25
26
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
ShelfSens
empty: Bool
isEmpty()
1
1
Button
id: Integer
litUp: Bool
push()
lightUp()
lightDown()
set()
reset()
checkTime()
Signals
timeOut()
1
3
1
Controller
price: Integer
request(Integer)
checkAmount()
checkAvailability()
ShelfRel
3
release()
28
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
}
31
Active Objects
Define a statechart for each object
Communication through signals
E.g., SDL: asynchronous send, synchronous receive
Synchronous communication requires sending a request
and waiting for the response
Avoid variables shared between processes
Overview
What is OO Analysis & Design?
Vending Machine Example
Analysis
Use case modeling
Domain modeling
Behavioral modeling
Design
Interaction diagrams
Refined class diagram
Concurrency and scheduling
Summary
Analysis
Use case analysis - writing user stories
Structural analysis/domain modeling - finding real-world objects
Behavioral analysis
Creating activity diagrams and sequence diagrams to capture use case
details
Creating state charts to capture external reactive behavior of the
system and other domain objects
Design
Further Reading
Recommended OO Analysis & Design
book:
Applying UML & Patterns: An Introduction to
Object-Oriented Analysis and Design and
Iterative Development by Craig Larman, 3rd
edition, Prentice Hall, 2004
35