{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 8 Structured Design for Methods and Modules

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

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

Lecture 8: Structured Design  and Object Oriented Design CSE 111 01/08/11 1 Copyright William. E. Howden

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
Structured and Go-to-less  Programming Modern programming languages, with  compound statements that match SP

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern