Chapter 6 – System Design II: Behavioral Models
Dec 30, 2015
Chapter 6 – System Design II: Behavioral Models
6.1 Models
Models - what do you think of?
2
A model behaves like (some part of) the intendedsystem, but in a more convenient way.
A good model should be • Abstract• Unambiguous• Allow for innovation• Standardized• Facilitate good communication• Modifiable• Remove unnecessary details & show important features• Break system into sub-problems.• Substitute sequence of actions by a single action.• Assist in verification• Assist in validation
3
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
5
6.2 State DiagramsExample: Vending Machine
$0.05
$0.10
$0.15
$0.20
Initial/Reset:$0.00
dime
nickel
nickel
nickel
nickel
nickel
>= $0.25
dime
dime
dime
dime
Steady Discrete“States”
Start Here(also a state)
Transitions
Inputs thatCausetransitionsWhere are the
outputs?
Just names of states. Should not have confused the issue
We’ll try doing it properly.
7
$0.05
$0.10
$0.15
$0.20
Initial/Reset:$0.00
dime
nickel
nickel
nickel
nickel
nickel
>= $0.25
dime
dime
dime
dime
Moore MachineOutputs on transitions
Mealy MachineOutputs for states
$0.00
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
8
Does not have to be graphical
Refined to a science withlots of theory
A lot like a programminglanguage.
Flowcharts
Symbols:
9
TerminatorGeneralProcess
ElaboratedProcess
GeneralData
DisplayedData
Stored Data Direct Data
Decision
Example: Light Monitoring System
• Can you figure out the operation of the system by looking at this?
• That is why the flowchart is elegant and not so lowly. Hah!
10
Samplelight
strengthStart
Computelight
sampleaverage
Store samplevalue inarray
Displayaveragevalue
Key-press?
Wait 1ms End
no
yes
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
11
6.4 Data Flow Diagrams
Intention is ???
• DFDs can have levels, just like the functional
12
Process InterfaceData StoreData Flow
Example: Video Browsing System
13
VideoDatabase
ShotBoundaryDetection
AnnotationDatabase
Video
BoundariesKey
Frames
User
BrowseRequest
StoryboardPreview
Storyboard
KeyFrames
Boundaries
Shot Preview
Shot PreviewRequest
Video
Shot
The Event Table
Event Trigger Process Source
Annotate Video
New Video Arrival
Shot Boundary Detection
System
View Storyboard
Browse Request
Storyboard Preview
User
View Shot Shot Preview Request
Shot Preview
User
14
VideoDatabase
ShotBoundaryDetection
AnnotationDatabase
Video
BoundariesKey
Frames
User
BrowseRequest
StoryboardPreview
Storyboard
KeyFrames
Boundaries
Shot Preview
Shot PreviewRequest
Video
Shot
6.5 Entity Relationship Diagrams
• Intention of an ERD is
• Entities =
• Relationships =
• Attributes =
15
Example: College Database System
To
From
Student Course Department
Student takes: one to many
major: 1 to ≥1
Course has:one to many
pre-req for: one to anyrequires: one to any
offered by: one to one
Department
has majors: one to many
offers: one to many
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
16
College Database ERD
17
Student SSN Name Date of birth Age GPA Major
Department Name Chair # of students
Course Number Department Credits Instructor Available Seats
takes /has
offers /offered by
majors in/enrolls
requires /is prereq
M
M
M1
M
M
M
1
Try Again
18
Student SSN Name Date of birth Age GPA Major
Department Name Chair # of students
Course Number Department Credits Instructor Available Seats
takes /has
offers /offered by
majors in/enrolls
requires /is prereq
M
M
M1
M
M
M
1
UML - Scenario
• Pretty popular idea – web ordering of groceries followed by home delivery.
• The “v-Grocer” system.• User has a barcode scanner connected to home
computer.• They can scan a used item an automatically order it
from the grocery store.• Place the order and groceries delivered at pre-
arranged time.
19
Static View
• Object view of software.• Classes represent
• Data• Methods (functions) that operate on the data
• Objects are
• Can allow for different security levels.
20
+ChangeAddr() : bool
-Name : string-Address : string-CustId : long
Customer
Class Diagram
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
21
+ChangeAddr() : bool
-Name : string-Address : string-CustId : long
Customer
+ChangePrice()
-UPC : string-Cost : decimal-Type : string
Item
+TotalCost() : float
-OrderID : long-CustId : long
Order
+AddItem()
-UPC-OrderID-Quantity
GroceryCart
*
-contains
*
-part of
-Time : string-OrderId : long-CustID : long
Delivery-receives
*
-sent to
1
-sent by1
-contains1
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
22
Use-Case View
• Intention = • Characterized by a Use-Case Diagram
23
Customer
v-Grocer
WebOrder
WebServer
Database
Delivery
Clerk
AssembleOrder
DeliverOrder
Who’s involved in which activities
“Use-Case”= activityor procedure
Actors or Agents
Use-Case Description
Use-Case WebOrder
Actors Customer, Database, and WebServer
Description This use-case occurs when a customer submits an order via the WebServer. If it is a new customer, the WebServer prompts them to establish an account and their customer information is stored in the Database as a new entry. If they are an existing customer, they have the opportunity to update their personal information.
Stimulus Customer order via the GroceryCart.
Response Verify payment, availability of order items, and if successful trigger the AssembleOrder use-case.
24
State Machine View
25
Present login
Read password
Query server
loaded
! enter
enter
! response
Order page
recognized
! recognized
! loaded
Activity View• Intention = describe a sequence of activities needed to complete a
task.
26
Complete order
Post to clerk
Post todelivery
Assemble order
Incorporate intoschedule
Send items
Determinedelivery route
Collectorders
Run delivery
This is really just a Petri Net used very badly.
Look up “Petri Net”.
Interaction View
• Intention = to show interaction between objects (when they must cooperate to do something useful).
• Use either a collaboration or sequence diagram.• This example is for the WebOrder use-case.
27
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
28
Design for Electrical and Computer Engineers (Published by McGraw Hill)Not to be transmitted or reproduced without written consent of authors
Copyright 2005 Ralph M. Ford and Chris Coulston
29
Physical View• Show the physical components that constitute the
system.• Can think of this much more generally than
presentation in UML.
30
6.8 Summary
• Models are an abstraction of system.• Models can be thought of as a design specification.• Models have different intentions for describing
behavior.• Models should encourage innovation and provide
for clear documentation.
31