5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin- Stout John Wiley & Sons, Inc. PowerPoint Winifred J. Rex Presentation Bowling Green State University 10th edition
24
Embed
5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
5-1
Structured COBOL Programming
Nancy Stern Hofstra University
Robert A. Stern Nassau Community College
James P. Ley University of Wisconsin-Stout
John Wiley & Sons, Inc.
PowerPoint Winifred J. Rex Presentation Bowling Green State University
10th edition
5-2
Chapter Objectives
To familiarize you with
11 Structured programs
11 Pseudocode
11 Hierarchy or Structure Charts
11 Logical Control Structures
5. Good programming techniques
6. Interactive processing
5-3
Well-Designed Programs
Are structured programs – when using procedural languages (COBOL, C, …)
• Use instructions executed in standardized order
• Divide program into modules, each performing a specific function
• Control returns to place module called from
• Simple PERFORM used in COBOL to execute modules (paragraphs)
5-4
Well-Designed Programs
Use top-down approach• Code modules in hierarchical order• Main modules first, then secondary modules
with detailed code• Step-wise refinement• Top modules are ‘control’ modules;
abstract; drivers; contain ‘Performs’…• As we go down the hierarchy, control
becomes less and computations and data manipulation becomes greater.
5-5
Well-Designed Programs
Are modular• Group related statements together into
modules• Execute each module or paragraph in
COBOL with simple PERFORM• For example, statements to calculate
students’ tuition in one module, statements to calculate room and board in another module
5-6
Designing Before Coding
• Design program first– So program will work efficiently– So program works as integrated whole– Design techniques applicable to all
languages
Code program only after design done– Use syntax rules of language– Syntax rules are language-specific
5-7
Pseudocode
• Primary tool for planning program logic
• We will use structure charts for our architectural design and pseudo-code for our lower-level detail (algorithmic) design.
• Specifies instructions and logical control structures used by program
• Use one or more lines of pseudo-code to describe each program step
5-8
Four Logical Control Structures• Used by structured programs to specify order
in which instructions are executed
1. Sequence
2. Selection
3. Iteration
4. Case Structure
All programs may be written using some combination of these control structures!
5-9
Sequence• Instructions executed in order they appear• Three instructions below executed one after the