+ All Categories
Home > Documents > © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of...

© Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of...

Date post: 11-Jan-2016
Category:
Upload: allan-parks
View: 220 times
Download: 0 times
Share this document with a friend
29
© Andrew Ireland Software Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh
Transcript
Page 1: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Function-oriented Design

Andrew IrelandSchool of Mathematical & Computer Sciences

Heriot-Watt UniversityEdinburgh

Page 2: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Outline

• Motivations • Data flow• Structuring• Detailed design

Page 3: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Motivations • Many significant software systems fall into this

classification, e.g. transaction processing

• Many legacy applications were developed using function-oriented design

Page 4: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Function-oriented Design • Applicability:

– Minimal system state– Information is typically communicated via parameters

or shared memory– No temporal aspect to functions, i.e. the result of a

function invocation is not dependent upon the function’s earlier invocations

• Approach:– Promotes a top-down functional decomposition style

of design

Page 5: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Function-oriented Activities• Data flow design:

– Model data flow through the system as a set of data flow diagrams

• Structural decomposition:– Model the functionality of the system as a

hierarchy of sub-functions via the structure chart notation

• Detailed design:– Provide detailed data and functional descriptions,

typically supported by the notion of a data dictionary

Page 6: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Data Flow Diagrams

• Data Flow Diagrams (DFDs) are used to

represent the flow of information through a

system, i.e. how the system outputs are derived

by the functional transformation of input data

sources• DFDs are used within many design methods and

are supported by numerous computer assisted

software engineering (CASE) tools• No standard notation …

Page 7: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

DFD Notation

User interaction with the system, i.e. input/output

Data store, e.g. database, files, etc

System function/operation/process

Labelled data flow

Note: data flows can be combined logically, i.e. and/or

Page 8: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Example: Regression TestingTesting that code modifications have not regressed the

correctness of the system as a whole:

“Also as a consequence of the introduction of new bugs,

program maintenance requires far more system testing

per statement written than any other programming.

Theoretically, after each fix one must run the entire batch

of test cases previously run against the system, to

ensure that it has not been damaged in an obscure way.

In practice, such regression testing must indeed

approximate this theoretical idea, and it is very costly." Fred Brooks, The Mythical Man Month (p 122)

Page 9: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Example: Regression TestingConsider the following system requirements:

1. A user provides a name for a source code base

2. If valid, then the source code base is retrieved from a database

along with its associated regression test suit, which is held in a

separate database

3. The source code is executed against the regression tests

4. The test results are compared against the expected results, which

are held in another database

5. If actual and expected results differ then a report is generated for

the user, else a certificate is generated for the user

6. A log file summarizing the regression testing stored in a database

Page 10: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

DFD ExampleSource code db

Test case db

Expected results

db

Run tests Compare

Gen Log

Gen reports

Gen reports

Gen certifs

Validate

Regression test db

and

or

s_file

t_file

e_file

a_resr_res

r_res

idid

l_file

r_file

c_file

report

certif

Data flow

Page 11: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Exercise: Wanted PersonsConsider the following system requirements:

1. A user provides facial features based upon crime reports

2. If valid, then the feature list is used to retrieve a list of relevant

feature templates from a database. If the feature list is not valid

then an error message is sent to the user

3. The feature template list is used to search for matching offender

imagines which are stored within an offender records database

4. Any records for offenders already in prison are then pruned

5. From pruned list, a suspect list is dispatched to the user, while the

corresponding records are sent to a “wanted persons” database

Exercise: construct a DFD for the requirements above

Page 12: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Exercise: Wanted PersonsConsider the following system requirements:

1. A user provides facial features based upon crime reports

2. If valid, then the feature list is used to retrieve a list of relevant

feature templates from a database. If the feature list is not valid

then an error message is sent to the user

3. The feature template list is used to search for matching offender

imagines which are stored within an offender records database

4. Any records for offenders already in prison are then pruned

5. From pruned list, a suspect list is dispatched to the user, while the

corresponding records are sent to a “wanted persons” database

Exercise: construct a DFD for the requirements above

Page 13: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

DFD Example

offenderimage

db

feature template

db

filtertemplates

validate features

and

feature list

images

features error-msg

suspect list

get feature list

prisonrecords

db

matchimages

extractsuspects

wantedpersons

db

records

templates

or

records

feature list

template list

images

Page 14: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Hierarchical DFDs • As system complexity grows, so will the DFDs• Hierarchical, or layered, DFDs provide a way of

managing this complexity, i.e.• Firstly, a Context Diagram (Level 0) is used to

model the system as a single system process together with the environment in which it operates, e.g. users and external data stores

• Then, Level 1, 2, 3 … DFDs are developed, which model the system’s sub-processes

Page 15: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

A Context Diagram (Level 0)

0

Page 16: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Level 1 DFD

1

2

Page 17: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Level 2 DFD

1.1 1.2

2.1 2.2

Page 18: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structural Decomposition • For a given DFD there will exist choices as to

how it is implemented• The structure chart notation provides a means of

adding more structure to the design• Each function (or procedure) is represented as a

rectangle• A high-level function is represented as a

hierarchy of sub-functions• Links between sub-functions are labelled with

input/output data, i.e. parameters or shared data

Page 19: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structural Decomposition

A

y

A

y

x x

A

x y

A

x x

input output transform Co-ordinate

Page 20: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structural Decomposition • Note that a structure chart shows the relationship

between sub-functions, but not the order in which they are invoked

• Typically a series of structure charts are developed for a given DFD – incrementally expanding level by level, e.g.

A

B C

A

B C

D E F

x x

x

z

v

u

r

s

t

z

Page 21: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structural Decomposition A

B C D

E F G H

K

I J

input outputprocess

Page 22: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structural Decomposition A

B C D

E F G H

K

I J

decisionmaking

dataprocessing

Page 23: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structure Chart: FirstRegression tester

Initialize ReportTest

Source code

Test cases

Expected results

Source code id

Regression results:• regression log• defect report• certificate

id

idres

res

Page 24: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structure Chart: SecondRegression tester

Initialize

Report

Test

Source code

Test cases

Expected results

Regression log

id

idid

Validate

Run tests

Compare

id

res

Logger

Generator

id a_res

r_res

r_res

r_res r_res

Defect

report

Certificate

r_res

Page 25: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Structure Chart: ThirdRegression tester

Initialize

Report

Test

Source code db

Test case db

Regression test db

id

idid

Validate

Run tests

Compare

id

res

Logger

Generator

Gen cert

Gen report

id a_res

r_res

r_res

r_res r_res

r_file c_file

Expected results

db report cert

l_files_file t_file e_file

r_res

Page 26: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Detailed Design • Detailed design involves getting inside the

functional blocks represented with the structure chart notation

• At this level, Process Description Languages (PDL), i.e. pseudo code

• A useful intermediate representation is a Data Dictionary (DD) – a structured, but informal, record of data items and functional

• DDs are useful to designers, programmers as well as during maintenance

Page 27: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Example: Data Dictionary Entity Type Description

id string Name of the source code base under test

res boolean The result of validating the name of the source code base provided by the user

… … …

r_res vector The regression test results, i.e. the actual results vs expected results

a_res vector The actual results obtained by executing the code base against the regression tests

test procedure Input: name of source code base

Function: co-ordinates the execution of the regression tests and the comparison with the expected results

Output: results of regression testing

… … …

Page 28: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Sequential vs Concurrent

• Note that no explicit reference has been made as to how a design is implemented, i.e. sequential vs concurrent

• DFDs in particular do not impose a control paradigm

• A DFD representation of a function could be implemented as a:– sequence of sub-function invocations or – set of communicating processes

Page 29: © Andrew IrelandSoftware Design F28SD2 Function-oriented Design Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University Edinburgh.

© Andrew IrelandSoftware Design F28SD2

Summary • Learning outcomes:

– Applicability of function-oriented design– Data flow and DFDs– Structure charts and functional hierarchy– Detailed design and data dictionaries

• Recommended reading:– D. Budgen, “Software Design”, Addison-Wesley 2003– I. Sommerville, “Software Engineering”, Addison-

Wesley 2007


Recommended