Delete

advertisement
Ex_5.1/21
Exercise 5
Stepwise Refinement
Stepwise Refinement – Case StudyEx_5.2/21

Design a product to update a sequential master file
containing name and address data for monthly
magazine True Life Software Disasters,

Three types of transactions:
– Type 1: INSERT (new subscriber into master file)
– Type 2: MODIFY (existing subscriber record)
– Type 3: DELETE (existing subscriber record) ,

Transactions are sorted into alphabetical order,
and by transaction code within
alphabetical order.
Typical File of Input Transactions Ex_5.3/21
Delete
Insert
Update
Delete
Insert
…
Decompose Process

No further refinement is possible ,
Ex_5.4/21
First Refinement

Take couple of minutes to define the
process algorithm.
Ex_5.5/21
SR – Case Study (Cont’d)

Ex_5.6/21
Assumption
– We can produce a record when PROCESS requires it,


Separate INPUT and OUTPUT, concentrate on
PROCESS ,
What is this PROCESS?
The Process…

Ex_5.7/21
Transaction Record Key = Old Master Record Key
– 1: INSERT – Print error message,
– 2: MODIFY – Change Master File Record,
– 3: DELETE – Delete Master File Record,

Transaction Record Key > Old Master Record Key
– Copy old Master File Record onto new Master File ,

Transaction Record Key < Old Master Record Key:
– 1: INSERT – Write Transaction Record to new Master File,
– 2: MODIFY – Print error message,
– 3: DELETE – Print error message.
Second Refinement
Ex_5.8/21
SR – Case Study (Cont’d)



Input and output have been deferred,
No provision for end-of-file ,
No specification for error condition.
Ex_5.9/21
Third Refinement
Ex_5.10/21
SR – Case Study (Cont’d)

Ex_5.11/21
The third refinement is WRONG
– Consider “Modify JONES” followed by “Delete JONES”!
SR – Exercise

Ex_5.12/21
Consider the effect of introducing the look-ahead to
the design,
i.e. before processing a transaction, the next
transaction must be read.
– If both transactions apply to the same master file record,
than the decision regarding the processing of the current
transaction will depend on the type of the next transaction,
– For example, two successive insertion of the same record
are clearly an error,
– But two successive modifications of the same record may
be perfectly valid – for example, a subscriber can change
address more than once in a given month.
SR – Exercise (Cont’d)


Ex_5.13/21
Assignment 1 (in pairs):
Draw up a 3x3 table with the rows labeled by
the type of the current transaction, and the
columns labeled by the type of the next
transaction, and fill in the action to be taken in
each instance,
Next
Insert Modify Delete
Current
Insert
Modify
?
?
?
?
?
?
Delete
?
?
?,
SR – Exercise (Cont’d) …


Ex_5.14/21
Assignment 2:
Develop a flowchart for a third refinement that
incorporates look-ahead ,
SR – Exercise (cont’d) …



Ex_5.15/21
Assignment 3:
Check whether your answer can correctly
handle a modification transaction followed by a
deletion transaction, both transactions being
applied to the same master file record,
If not, modify your answer ,
SR – Exercise (Cont’d) …



Assignment 4:
Check whether your answer,
can also correctly handle
insertion followed by
a modification followed by
a deletion,
all applied to the
same master file record,
If not, modify your answer ,
Ex_5.16/21
SR – Exercise (Cont’d) …



Assignment 5:
Check whether your answer,
can also correctly handle
n insertions,
modifications or deletions,
n>2,
all applied to the
same master file record,
If not, modify your answer ,
Ex_5.17/21
SR – Exercise (Cont’d)



Ex_5.18/21
Assignment 6:
The last transaction record does not have a
successor.
Check whether your flowchart takes this into
account and processes the last transaction
record correctly,
If not, modify your answer ,
SR – Exercise (Cont’d)



Ex_5.19/21
Assignment 7 & Last ;-)
Verify that your flowchart handles all test cases
correctly!,
If not, modify your answer ,
Assignments


Ex_5.20/21
Article:
Synchronize and Stabilize vs. Open-Source
Webassign
Ex_5.21/21
Exercise 5
Stepwise Refinement
The End
Download