1 / 14

Oct 18

Oct 18. Homework #1 Review of Structure Diagrams, Basic JSP Method Read ahead rule. Homework. HW #1 http://pmik.petrsu.ru/pub/ourusoff/Intro to JSE/Home Work/ due noon, Friday, 21 Oct email solution as (zipped) attachment to: nourusoff@psu.karelia.ru. Remarks on JSP.

talisa
Download Presentation

Oct 18

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Oct 18 Homework #1 Review of Structure Diagrams, Basic JSP Method Read ahead rule

  2. Homework • HW #1 http://pmik.petrsu.ru/pub/ourusoff/Intro to JSE/Home Work/ due noon, Friday, 21 Oct email solution as (zipped) attachment to: nourusoff@psu.karelia.ru

  3. Remarks on JSP • Use structure diagrams, not flow charts to design programs • Flow charts show the flow of control in a program. • A flow chart examines the dynamic representation of a program: "What happens next?“ • Instead of thinking about the structure of the program, the programmer will think about its execution in the computer. • Design is about the relation of parts to the whole. • So, the design of a program follows from the static structure of a program's text:

  4. Remarks on JSP • There is a difference between getting a program to work and getting it right. • A program may work, but may be wrong--it may be difficult to read, may not model the problem to be solved, may be difficult to maintain. • If a program is right, e.g. it has the correct structure, it will be easier to read and maintain. Thus, maintenance costs are minimized.

  5. Remarks on JSP • JSP is a constructive design method. According to Jackson, a software engineering methodmust give step-by-step guidance as to how the design is proceeding In JSP criteria guide the designer at each step of the design process. • We construct a model of the task to be solved in the form of a data structure. • This data model guides the design of the program. Like step-wise refinement, JSP is a structured programming methodology, e.g. it relies on control structures for sequence, selection and iteration

  6. Remarks on JSP Modular programming (prevalent in the 1960's) design method has no decision procedure to guide the designer in the choice of modules. In step-wise refinement (proposed as a design method by E. Dijkstra in the 1970's), design proceeded by top-down decomposition using the control structures of structured programming (sequence, selection and iteration). • There is no decision procedure to guide the designer. • Moreover, the biggest decomposition decision must be made right away--the first decomposition--when we have little experience with the problem at hand.

  7. Remarks on JSP • Jackson gives us a rule about optimizing programs for efficiency. The rule is as follows: • Don't optimize! • If you have to, do it as the last step, after you have designed the program properly. The reasons for the rules about optimization are: • optimization is often unnecessary, and • optimization distorts the structural correspondence between a program and the problem it models,making it more difficult and expensive to maintain.

  8. Notes on Selection • the condition must be evaluated before we can determine which component we have • one part of a selection must be selected. • If we want no part to be selected, we need to add to the existing parts one whose condition is “not any of the other parts” • The order in which the parts are listed in the selection is immaterial

  9. Degenerate selection • Sometimes we have a situation in which data occurs or doesn't, depending on some condition. This form of degenerate selection is depicted by the following structure diagram and text representation: • The structure diagram can be abbreviated as shown below:

  10. Sequence within composite structures • Generally, we will be explicit in depicting composite structures. If a sequence is part of a component that is not the root of the structure, however, we will relax the explicit begin....end demarcation for sequence, as is shown in the following example:

  11. JSP Patterns:Read Ahead Rule Allocating the read operation: a “proof by contradiction” Suppose we have a file, F, consisting of two records, T1 and T2. How should we allocate read operations?

  12. Read-ahead Rule • Assume read is 1st operation in P1 and P2 components (derivation_i) • Modify the problem: suppose T1 may not be present, T2 is always present (derivation_ii) • Must put initial read prior to test for presence of T1 in P1 • But, if T1 is absent, the 2nd read in P2 will read beyond end of file • Thus,we must allocate the 2nd read at the end of the P1 component (derivation_iii)

  13. Read-ahead rule (cont.) The read-ahead rule: • Place the initial read immediately after opening a file, prior to any component that uses a record; place subsequent reads in the component that processes a record, immediately afterthe record has been processed. • The effect of the read-ahead rule is to have the next record (if any) available at the start of any component that may process it.

More Related