Lecture 8 Structured Design for Methods and Modules

Lecture 8 Structured Design for Methods and Modules -...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 8: Structured Design  and Object Oriented Design CSE 111 01/08/11 1 Copyright William. E. Howden
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Structured Design Software engineering for procedural  programming Detailed design Structured Programming Constructing “well structured” programs structure refers to control-flow as in a flow chart Architectural Design Components and relationships Components:  (collections of) procedures and methods 01/08/11 Copyright William. E. Howden 2
Background image of page 2
Detailed Design Structured Programming Goal: well-structured programs Basic idea restrict all program structures to those that  can be constructed from several basic  constructs, plus a well defined rule of  composition for building new structures  01/08/11 Copyright William. E. Howden 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Three Basic Structured  Programming Constructs Sequencing S1; S2 Alternation if C then S1 else S2 Iteration while C do S1 Variations on the above one-sided alternation, until and for loops, switches 01/08/11 Copyright William. E. Howden 4
Background image of page 4
Elements of a Construct Each element Si in the above diagrams is: another structured programming construct a procedure/method call an elementary statement such as an  assignment or basic operation such as a  string edit Each element Ci is a Boolean expression 01/08/11 Copyright William. E. Howden 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Composition: Constructing More  Complex Structures by Nesting  Start with statement S: e.g. if C1 then T1 else T2 then nest additional constructs inside S by substituting them in  for T1 and T2 We can do this repeatedly, to get, for example: if C1 then( if C2 then (S1; (S2; S3)) else S4) else (while C3 do  (S5; S6)) this has been constructed from one double-nested  application of sequencing, 2 nested sequencings, 1  nested alternation and 1 nested iteration 01/08/11 Copyright William. E. Howden 6
Background image of page 6
Compound Construct Formatted  for Readability if C1 then( if C2 then (S1; (S2; S3)) else S4) else (while C3 do (S5;  S6)) if C1  then( if C2  then (S1; S2; S3))  else S4)  else (while C3 do  (S5; S6)) 01/08/11 Copyright William. E. Howden 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic “Axioms” of Structured  Programming  Adequacy:  all computations can be  programmed using the three basic constructs  plus the nesting rule of program composition Well-structured: if this approach to construction  is used, then it is not possible to construct  “poorly structured” code poorly structured code?  “spaghetti code”, goto’s all over the place 01/08/11 Copyright William. E. Howden 8
Background image of page 8
Structured and Go-to-less  Programming Modern programming languages, with  compound statements that match SP 
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/07/2011 for the course CSE 111 taught by Professor Howden during the Fall '07 term at UCSD.

Page1 / 34

Lecture 8 Structured Design for Methods and Modules -...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online