functions

advertisement
Functional Modeling
Joseph Valacich, Joey George and Jeff Hoffer,
Essentials of System Analysis and Design, 4th edition,
Prentice Hall, 2009.
Review: Modeling
• Functional: what happens
• Dynamic: when it happens
• Static: what it happens to
2
Functional Models
• Describes computations and transformation of data
– How are outputs derived from inputs
– Specifies results of computations, not how or
when they are computed
input x
program
y = f(x)
output y
3
Functional Models (Cont.)
• Does not describe timing
– Has no regard for order of operations
– No control information
– Not a flow chart
• Uses diagrams
– Use cases
– Data flow diagram (DFD, not a UML diagram)
– Activity Diagrams
4
Steps in Constructing
Functional Model
• Identify input and output values
• Build data flow diagrams showing
functional dependencies.
• Describe the functions.
• Identify the constraints.
5
1. Identify Input/Output
• At the highest level of abstraction, these
are the system inputs and outputs.
• Each lower level has inputs and outputs
defined by some higher level.
input x
program
output y
6
2. Build Diagrams
• Start with each output and determine what
function computes it.
• (Or trace forward from inputs.)
• Expand each non-trivial process in a higherlevel diagram by constructing a lower-level
diagram.
f1
f11
f13
f12
7
3. Describe Each Function
• Write a description of each function
(using any of the specification
techniques discussed earlier).
Function, f: Integer  Integer, such that
f(x) = -1 if x < 0
f(x) = 0 if x == 0
f(x) = 1 otherwise
8
4. Identify Constraints
• Constraints are functional dependencies between
objects that are not related by an input-output
dependency.
– Between two objects at the same time
– Between instances of the same object at different
times
– Between different objects at different times.
• State the time the condition must hold.
• E.g. “no account balance may ever become
negative.”
9
Specifying Functions
• Need a signature (syntactic or interface)
• Need transformations (semantics or meaning)
10
Specifying Functions (Cont.)
• Need a signature (syntactic or interface)
– Name
– Arguments (number, order, types)
– Values returned (number, order, types)
• Need transformations (semantics or meaning)
11
Specifying Functions (Cont.)
• Need a signature (syntactic or interface)
• Need transformations (semantics or meaning)
–
–
–
–
–
–
Functions and equations
Tables of values
Pre and post conditions
Decision tables
Pseudo code
Natural language
12
Functions
• Trivial
– Access: read or write attributes. May not
be necessary to show all of these.
• Non-trivial
– Queries: no side effects
– Actions: “instantaneous” (atomic)
– Activities: duration over time
13
Documenting Functional Models
• Uses diagrams
– Data Flow Diagram (DFD)
– UML Activity Diagram
14
Data Flow Diagram (DFD)
• Semi-formal notation for specifying
– Functions of an information system and
– How data flow from functions to functions
• Describes systems as
– Collections of functions that manipulate data
– Data can
• Be stored in data repository,
• Flow in data flows, and
• Be transferred to or from the environment.
15
DFDs Are Not For Specifying
• Order of operations (functions)
• Control information
• Flow charts
16
DFD Notation
• Four components
– Processes
– Data flows
– Data stores
(or
)
– Sources/sinks
17
Example DFD
exam scores
Compute
average
Grade book
student names
exam scores
average score
names
grades
Compute
grades
names
grades
Output
grades
18
Processes
• Transform data values
• Drawn as ellipses with fixed number
of in-arrows and out-arrows
dividend
quotient
Divide
Integer
divisor
remainder
19
Data Flows
•
•
•
•
Connect processes
Represent intermediate data
Values are not changed by data flow
Arrow with name or type of data
integer
a
copy
city
street
city
address
zip
zip
aggregation
address
split
20
Data Store
• Stores persistent data for later use
• Has exactly two operations:
– Store
– Retrieve
• Drawn as:
data store
(or
data store
)
21
Sources/Sinks
• Producers or consumers of data
• Also called terminators and actors
Customer
Printer
Printer
Producer (source)
Consumer (sink)
22
DFD Example 1
Price Lists
Price List
Item Name
Cost
Find Cost
23
DFD Example 2
Grade Book
Teaching
Assistant
Grades
IDs
Grades
3. Compute
statistics
Final
grades
Average
IDs
Grades
1. Enter
grades
2. Adjust
grades
Average
Median
Names
Grades
Names
Final grades
Printer
Printer
Grade
report
4. Create
report
24
Data Dictionary
• Repositories to store information about all data
items defined in the DFD
• DD may include:
–
–
–
–
–
–
Name of data item
Aliases (other names for item)
Description and purpose
Range of values
Data flow (generated by, used by)
Data structure definition and form
Alan Davis, Software Requirements, Prentice Hall, 1993.
25
DD Example
26
In Class: Candy Machine
Pairs (5 minutes): Model the function of a candy
machine described below.
–
–
–
–
–
–
–
Customer inserts coins
Machine validates coins
Customer selects a candy
Machine validates candy selection
Machine validates transaction
Machine dispenses change
Machine dispenses product
27
Organizing DFDs
• Apply levels of abstraction (leveling)
• The initial DFD is:
input
program
output
• This can be expanded into lower
levels.
• Eventually, the process must stop.
– When atomic processes can be
described.
28
Context Diagram (Level 0)
• Describes the system at the highest, most
abstract level.
• Determines the scope of the system
• Provides a general view of the system
environment identifying external interfaces.
• Comprised of:
– One bubble (the name of the system)
– System terminators (sources and sinks)
– External inputs and outputs
29
Level 0: Payroll System
Pay info
Employee
info
Employee
Printer
Timecard
info
Printer
Printer
Process
Payroll
Acct info
Accountant
Printer
30
Concept of Leveling:
Rules of Decomposition
I1
1. A
I2
I1
O
Level n
dx
1.1 J
dx
I2
1.2 K
O
1.3 L
dy
dz
dy
Data storage
Level n+1
31
Concept of Leveling:
Rules of Decomposition (Cont.)
I
1. B
O
Level n
O1
dx
1.1 J
I
I1
I2
dy
1.3 L
O
O2
dy
1.2 K
Level n+1
32
Level 1: Payroll Process
Inputs and outputs
to level n+1 match
level n
Employee
info
Pay info
4: Format
paycheck
3: Calculate
withholding
Acct. Info
Timecard
info
1: Validate
timecard
Valid
timecard
info
Pay info
(formatted)
Gross
pay
2: Calculate
gross pay
5: Format
accounting
Acct. Info
(formatted)
Level 2: Calculate Withholding
Emp. info
3.1: Compute
withholding
rate
Rate
Pay info
Gross pay
3.2: Compute
net pay
Acct. info
34
Notes:
• Show all possible computation paths for
values.
• Do not show what paths are executed in what
order (that’s the job of the dynamic model).
• There may be many Level N+1 diagrams for
each Level N diagram. Level N+1 expands a
single node of a Level N diagram.
35
Guidelines for Designing
DFDs
1. Describe the system at the highest, most abstract
level (context diagram)
2. Decompose the system and represent it as a
DFD with multiple bubbles.
2.1 Document the processes
2.2 Fill out the data dictionary
3. Decompose a process (following step 2) until the
problem is understood
36
Identifying Data
• At the highest level of abstraction, these
are the system inputs and outputs.
• Each lower level has inputs and outputs
defined by some higher level.
37
Identifying Processes
• Start with each output and determine
what function computes it.
• (Or trace forward from inputs.)
• Expand each non-trivial function
(process) by constructing a lower-level
diagram.
38
Things to Check in DFDs
1. Is each requirements function represented
by a transform in the DFDs?
2. Is each system input and output represented
in the DFDs?
3. Is each I/O from a higher-level DFD
reproduced correctly on the lower-level
DFDs?
4. Is each transform in the lowest-level DFDs
primitive?
39
Things to Check in DFDs
5. Are all labels of information flows in the data
dictionary?
6. Do all data dictionary entries appear in the
DFDs?
40
In Class: Groups of 3
•
•
•
Draw the DFD for the gas pump controller
(see handout).
Draw a Level 0, Level1, and 2 Level 2
diagrams.
(15 minutes)
41
Download