Presentation is loading. Please wait.

Presentation is loading. Please wait.

Structure clashes and program decomposition

Similar presentations


Presentation on theme: "Structure clashes and program decomposition"— Presentation transcript:

1 Structure clashes and program decomposition
15 Nov Structure clashes and program decomposition

2 Structure clashes The design method that has been presented in the preceding chapters works when there is a correspondence between input and output data structures. What happens when such correspondences don't exist, as in the following example?

3 Structure clashes: Net Movement Report
A warehouse records a transaction for every item received into or issued out of the warehouse. At the end of the day, the transaction file is sorted by item number, and a "Daily Net Movement Summary" showing the net movement of each item into or out of the warehouse is produced. The format is shown below: Daily Net Movement Summary A A Z End Summary

4 Net Movement Report System Diagram

5 Warehouse Net Movement input – output structure diagrams

6 Warehouse Net Movement Program Structure

7 Warehouse Net Movement: Elaborated program structure

8 Modified Net Movement Problem
Suppose the input file is blocked, with each block containing a record count followed by a number of records.

9 Modified Net Movement Problem: The essence of the difficulty
The program must have an operation that is executed once per block and an operation that is executed once per group So there must be both a block component and a group component But we cannot have a single program structure with process block and process group components. We have a boundary clash--the boundaries of blocks are not synchronized with the boundaries of groups.

10 Solution to Boundary Clash: Decomposition

11 Input, intermediate and report files, together with their correspondences

12 JSP Solution

13 Comments on JSP Solution
The programs we obtain are distinct. A serial file forms a boundary between any pair of programs. We don't have to think "dynamically". For example, we don't need to ask, "What if a group extends over several blocks?" or "What if a group has no data records?“ We know our programs are correct, because we can think in terms of static data structures Inefficient By introducing an intermediate file, we have roughly doubled the execution time (in comparison with a program that produced a report without an intermediate file). We will learn a little later how to optimize our design by a simple program transformation, program inversion.

14 Interleaving clash Let us suppose that our input file is incompletely sorted by part number. Total lines for each part group on the report may be in any order.

15 Solution to Interleaving Clash
Since the input file is not sorted completely by part number, we cannot show the group structure and the input file structure on one diagram. Our input file is an interleaving of part groups. To resolve this "interleaving" clash, we split the input file into part groups as shown below:

16 JSP Solution To resolve this "interleaving" clash, we split the input file into part groups as shown below:

17 Structure Clashes Three types of structural clash:
Boundary clash (physical blocks on input don’t coincide with logical groups on output) Boundary Clash Solution to Bounday Clash Ordering clash – for example, we wish a report sorted by a person’s last name (surname), but input is unsorted) Interleaving clash (wish to produce report of user job times, inputs are interleaved)

18 Solution to Structural Clashes
General view of problem Structure diagram Solution: program decomposition Program decomposition There is no structure clash between A and I, so the structure of PA can be constructed without difficulty; the same is true of I and X and PB

19 Processing of general view: batch processing (пакетная обработка данных)
Parallel processing Quasi-parallel processing (program inversion) program inversion

20 Program Inversion инверсия программ
We wish to design PA and PB independently of each other so that the structure of each is based on the data structure representation of its own problem environment. Program inversion is a purely mechanical transformation of the independent programs, PA and PB, into a main program and subroutine The subroutine has a single ENTRY point and stores its return address within its state vector so that it is resumable.

21 state vector (вектор состояния)
A program consists of: program text and variables text pointer to next instructionj to be executed state vector

22 Significance of program Inversion
Uses of inversion


Download ppt "Structure clashes and program decomposition"

Similar presentations


Ads by Google