slide1 l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL PowerPoint Presentation
Download Presentation
Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL

Loading in 2 Seconds...

play fullscreen
1 / 53

Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL - PowerPoint PPT Presentation


  • 366 Views
  • Uploaded on

Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL. CHAPTER 1 OBJECTIVES. To familiarize you with: 1. The reasons for COBOL’s popularity as a business-oriented language. 2. Some general programming practices and techniques.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL' - pembroke


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1
Chapter 1

INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL

Structured COBOL Programming, Stern & Stern, 9th edition

chapter 1 objectives
CHAPTER 1 OBJECTIVES
  • To familiarize you with:

1. The reasons for COBOL’s popularity as a business-oriented language.

2. Some general programming practices and techniques.

3. A history of COBOL’s evolution and its current ANS version.

4. An overview of how a COBOL program is structure.

Structured COBOL Programming, Stern & Stern, 9th edition

types of computer programs
Types of Computer Programs
  • A program is a set of instructions that enable a computer to process data.
  • Software is the term used to describe all types of programs.
  • An application programconverts input data to output information.

Structured COBOL Programming, Stern & Stern, 9th edition

ipo chart system flowchart
IPO Chart / System Flowchart

Identifies the inputs and outputs of the program. Basic IPO model.

EMPLOYEE FILE

PRINT PAYROL DATA

PAYROLL REPORT

Structured COBOL Programming, Stern & Stern, 9th edition

two types of computer programs
Two types of computer programs:

1. Operating Systems Programs

  • Control the overall operations of the computer

2. Applications Programs

  • Written by Programmers or Software Developers
  • Programs that perform tasks required by users
  • A set of programs that fulfill a business requirement is an Information System

Structured COBOL Programming, Stern & Stern, 9th edition

applications programs
Applications Programs

Interactive vs. Batch Processing

  • Interactive applications typically accept input data from a PC, workstation, or terminal.
  • Batch Processing applications process large volumes of input at periodic intervals.
    • Daily
    • Weekly
    • Monthly etc.

Structured COBOL Programming, Stern & Stern, 9th edition

applications programs7
Applications Programs
  • Applications programs that are written for a specific user are called customized programs.
  • Programs that are relatively standard are application packages that might be purchased.
    • Off The Shelf (OTS) may be less costly depending on the amount of customization needed

Structured COBOL Programming, Stern & Stern, 9th edition

machine language programs
Machine Language Programs
  • All programs executed by the computer must be in machine language – the only language a computer understands
    • Binary 10110101
    • Must know memory address of variables etc.

Structured COBOL Programming, Stern & Stern, 9th edition

symbolic programs
Symbolic Programs
  • Symbolic Programs use English-like or symbolicinstructions.
    • These programs must be translated or compiled into machine language.
      • Symbols (Variable/Data names) represent memory addresses
    • COBOL is a symbolic programming language used for commercial applications.
    • As is C++, Visual Basic etc.
  • A compiler coverts symbolic language into machine code

Structured COBOL Programming, Stern & Stern, 9th edition

program development process
Program Development Process
  • Determine Program Specifications
  • Design Program Using Program Planning Tools
  • Code and Enter Program
  • Compile Program
  • Test Program
  • Document Program

Structured COBOL Programming, Stern & Stern, 9th edition

program development process11
PROGRAM DEVELOPMENT PROCESS

1. Determine Program Specifications

  • Program Specifications consist of the following:
    • Record layout forms to describe the input and output (pg 6)
    • Printer spacing charts for printed output (pg 7)
    • Any special rules for processing

Structured COBOL Programming, Stern & Stern, 9th edition

i o specifications
I/O Specifications

The I/O specifications establish record names, field names, data sizes and types to be used in your program. For auxiliary storage specifications can take the form of an 01 level print out or a simply chart as follows.

 Used in developing the Data Division.

 Payroll-Record

Type Size

 Name Alphanumeric 30

Address Alphanumeric 23

Pay-Rate Numeric 5.2 or 7 with 2 decimals

Etc.

Structured COBOL Programming, Stern & Stern, 9th edition

program development process13
PROGRAM DEVELOPMENT PROCESS
  • Design the Program Using Program Planning Tools using Common Tools:
    • Hierarchy Charts
      • Charts showing relationships among sections in a program
    • Flowcharts
      • A block diagram providing a pictorial representation of the logic to be used in a program
    • Pseudocode
      • English-like expressions to depict the logic of the program

Structured COBOL Programming, Stern & Stern, 9th edition

hierarchy chart
HIERARCHY CHART

The first phase of problem solving is to use a top down design. Begin with a very general problem statement and break it down into smaller and smaller pieces until you know you have pieces you can solve.

 The hierarchy chart establishes the Paragraph names you will use in pseudo code and in your program’s Procedure Division. It outlines a very general program flow and shows the relationship between modules/paragraphs.

 Answers the question WHAT needs to be done?

Structured COBOL Programming, Stern & Stern, 9th edition

remember

REMEMBER

The sooner you start coding the longer it will take you to complete the project!!!!!

to reduce cost of fixing errors
To Reduce Cost of Fixing Errors

Structured COBOL Programming, Stern & Stern, 9th edition

program development process17
PROGRAM DEVELOPMENT PROCESS

3. Code and Enter the Program

  • The programmer writes and then keys or enters the source program into the computer system using a keyboard.

4. Compile the Program

  • The COBOL compiler checks the source code to insure there are no rule violations.
  • A syntax error is a type of error that is found if a programming rule is violated.

Source program in symbolic language

Translated by compiler

Object program in machine language

Structured COBOL Programming, Stern & Stern, 9th edition

program development process18
PROGRAM DEVELOPMENT PROCESS

5. Test the Program

  • Programs are tested or debugged to ensure they have no errors.
  • Runtime errors
    • A logic error produces incorrect results
    • An Operating System violation –results in program termination

6. Document the Program

  • Procedure manuals for users and computer operators, called documentation, is prepared for use by the operating staff for regular production.

Structured COBOL Programming, Stern & Stern, 9th edition

program development process19
PROGRAM DEVELOPMENT PROCESS
  • Remember, coding is undertaken only after the program requirements have been fully specified and the logichas been carefully planned.

Structured COBOL Programming, Stern & Stern, 9th edition

debugging techniques
DEBUGGING TECHNIQUES
  • Desk Checking
    • Reviewing the program before and after keying
  • Correcting Syntax Errors
    • Using the printed source list of the diagnostic messages to find and correct the errors

Structured COBOL Programming, Stern & Stern, 9th edition

debugging techniques21
DEBUGGING TECHNIQUES
  • Program Walkthroughs
    • Manually stepping through the program with test data.
  • Detecting Logic Errors by Executing the Program
    • Often the most difficult part of debugging.
    • The preparation of test data is an extremely critical aspect of debugging.

Structured COBOL Programming, Stern & Stern, 9th edition

the nature of cobol
THE NATURE OF COBOL
  • COBOL is a Business-Oriented Language
    • COBOL, is one of the most widespread commercial applications languages in use today.
    • COBOL is an abbreviation for COmmon Business Oriented Language,
  • COBOL is a Standard Language
    • COBOL is a common programming language available on most computers.

Structured COBOL Programming, Stern & Stern, 9th edition

the nature of cobol23
THE NATURE OF COBOL
  • COBOL is an English-like Language
    • All instructions can be coded using English words.
    • The rules conform to many rules for writing in English
  • COBOL is a User-Friendly Language
    • Because users are able to understand the English-like instructions it is considered a user-friendly language.

Structured COBOL Programming, Stern & Stern, 9th edition

when it began
WHENIT BEGAN
  • Developed in 1959 by the CODASYL Committee.
    • A committee consisting of representatives members from academia, user groups, and computer manufacturers.
  • Developed as a standard business-oriented language for which all major manufacturers would provide compilers.
  • ANS established the first standards version in 1968.
  • COBOL ’85 the current standard
  • http://www.ansi.org 2002+ Standard

Structured COBOL Programming, Stern & Stern, 9th edition

the future of cobol
THE FUTURE OF COBOL
  • COBOL is likely to remain an important language in the years ahead for two reasons:

1. Older, mainframe-based “legacy” systems will need to be maintained by maintenance programmers who know COBOL.

2. COBOL is still being used by many organizations for new application development.

Structured COBOL Programming, Stern & Stern, 9th edition

use of cobol
Use of COBOL
  • About 200 billion lines of COBOL source code in use
  • 5 billion new lines added each year
  • Used by 42.7% of application programmers in medium to large U.S. companies
  • $200 million in expected revenues for 2001

Structured COBOL Programming, Stern & Stern, 9th edition

interactive vs batch programs
Interactive vs Batch Programs
  • Cobol suited for developing both types of programs

Interactive programs

  • Accept input data from keyboard
  • Input data processed immediately
  • Output (results) displayed on screen immediately

Structured COBOL Programming, Stern & Stern, 9th edition

interactive vs batch programs28
Interactive vs Batch Programs

Batch programs

  • Process large volumes of input at periodic intervals
  • Input data read in from files
  • Output written to files

Structured COBOL Programming, Stern & Stern, 9th edition

techniques for improving program design
TECHNIQUES FOR IMPROVING PROGRAM DESIGN

Structured COBOL Programming, Stern & Stern, 9th edition

improving program design
Improving Program Design

Two techniques used to develop programs that are easier to understand, test, debug and modify

  • Structured Programming
  • Top-Down Programming

Structured COBOL Programming, Stern & Stern, 9th edition

structured programming
Structured Programming
  • Eliminates use of GO TO statements
    • Allowed skipping to different sections of program without returning to starting point
  • Program logic easier to follow with "GO-TO-less" programming

Structured COBOL Programming, Stern & Stern, 9th edition

structured programming32
Structured Programming

Program divided into paragraphs

  • Main paragraph or module controls logic flow using PERFORM statements
  • Main module "performs" other modules when instructions in that module required
  • Each module can be written and tested independently of others

Structured COBOL Programming, Stern & Stern, 9th edition

top down programming
Top-Down Programming
  • Another technique to make programs easier to understand, test, debug and modify
  • Develop program like term paper
    • Develop outline first
    • Add details for each of main steps
    • Add further refinement for more complex steps

Structured COBOL Programming, Stern & Stern, 9th edition

top down programming34
Top-Down Programming

For COBOL program

  • Code main modules or routines first
  • Code intermediate modules next
  • Details deferred to minor modules and coded last

Structured COBOL Programming, Stern & Stern, 9th edition

program specifications
Program Specifications
  • System Flowchart
  • Input/Output Specifications
  • Hierarchy Chart
  • Psuedo code
  • Narrative – as comments in program

Structured COBOL Programming, Stern & Stern, 9th edition

slide36

System Flowchart

INPUT

PROCESSING

OUTPUT

Attendance Report

PRINT STUDENT ATTENDANCE

Student-File

Structured COBOL Programming, Stern & Stern, 9th edition

slide37

START

OPEN FILES

READFIRSTRECORD

WRITEHEADINGS

PROCESSRECORDS

END OFFILEREACHED?

CLOSEFILES

STOP

Program Flow Chart

1

2

3

4

5

6

7

8

PROCESSRECORDS

ENGINEERINGMAJOR ANDMORE THAN

110 CREDITS

FALSE

TRUE

9

WRITESTUDENTNAME

10

11

READNEXTRECORD

12

STOP

(a) Overall Flowchart

Structured COBOL Programming, Stern & Stern, 9th edition

(b) Detail of PROCESS-RECORDS

slide38

Pseudo Code

Initialization

Processing

Termination

Open files

Read first record

Write heading

DO while data remains

IF engineering major with more than 110 credits Write student’s name

ENDIF

ENDDO

Close files

Stop

Structured COBOL Programming, Stern & Stern, 9th edition

hierarchy of data
Hierarchy of Data
  • Bit - binary 0 or 1
  • Byte / Character - 8 bits
  • Field - a basic fact about some entity
    • Customer - Current-Balance
    • Inventory - Selling-Price
  • Record - a collection of related facts
  • File - a collection of related records
  • Database - an organization’s set of files

Structured COBOL Programming, Stern & Stern, 9th edition

slide40

Jphn Adams 90 Political Science

John Adams 90 Political Science

Amelia Earhart 120 Aviation

Orville Wright 115 Engineering

Georgia O'Keeffe 125 Art

Georgia O’Keeffe 125 Art

Fields(Facts)

Records(Set of Fields)

Name: John AdamsCredits: 90Major: Political Science

Name: Amelia EarhartCredits: 120Major: Aviation

Name: Orville WrightCredits: 115Major: Engineering

Name: Georgia O’KeeffeCredits: 125Major: Art

Amelia Earhart 120 Aviation

Orville Wright 115 Engineering

Figure 1.1 Fields, Records, and Files

Structured COBOL Programming, Stern & Stern, 9th edition

programming structures
Programming Structures
  • Sequence
  • Selection
  • Iteration/Repetition

Structured COBOL Programming, Stern & Stern, 9th edition

structured programming using modular design for coding paragraphs
Structured Programming Using Modular Design for Coding Paragraphs
  • The most important technique for improving the design of a program in any language is called structured programming.
  • Structured Programming is a technique using logical control constructs that make programs easier to read, debug, and modify if changes are required.

Structured COBOL Programming, Stern & Stern, 9th edition

modular programming
Modular Programming
  • Each module/paragraph must meet the following characteristic
    • COMPLETENESS – taken together the modules completely satisfy the program specifications
    • COHESIVE – a paragraph must perform one and only one task
    • COUPLING – paragraphs are loosely coupled – that is a paragraph does not depend on other paragraphs

Structured COBOL Programming, Stern & Stern, 9th edition

structured programming using modular design for coding paragraphs44
Structured Programming Using Modular Design for Coding Paragraphs
  • Structured programming is often called GO-TO-less programming since programmatic branches do not use GO TO statements.
  • In COBOL this means writing programs using PERFORM statements

Structured COBOL Programming, Stern & Stern, 9th edition

structured programming using modular design for coding paragraphs45
Structured Programming Using Modular Design for Coding Paragraphs
  • The typical structured program is divided intoparagraphs or modules, where a main module calls in other modules as needed.
    • Each block on the hierarchy chart represents a paragraph
    • Each module can be tested independently.
      • Paragraph, routine, module are used interchangeably

Structured COBOL Programming, Stern & Stern, 9th edition

the top down approach for coding modules
The Top-Down Approach for Coding Modules
  • Proper design is best achieved by developing major modules before minor ones.
  • Main routines are coded first and are followed by intermediate routines and then minor ones.
  • Coding using the top-down manner gives the primary attention to the origination of the program.
  • Details are deferred or saved for minor modules, which are coded last.
  • Incremental testing

Structured COBOL Programming, Stern & Stern, 9th edition

hierarchy or structure chart
HIERARCHY OR STRUCTURE CHART
  • Structure charts illustrate the logic flow in a program.
    • The following chart shows the relationships among modules in a program:

100-MAIN

MODULE

200-INITIALIZE

210-WAGE

ROUTINE

Structured COBOL Programming, Stern & Stern, 9th edition

rules for interpreting pseudocode
RULES FOR INTERPRETING PSEUDOCODE
  • Each block on the Hierarchy chart needs to be represented in pseudocode
  • Paragraph names are prepared in numerical sequence
      • 100-Main-Module
      • 200-Initialize
      • 210-Wage-Routine
      • 220-Finalize-Program
      • Etc…
  • The instructions between the:

PERFORM UNTIL NO MORE DATA

executed repeatedly UNTIL there are no more records to process

END-PERFORM.

Structured COBOL Programming, Stern & Stern, 9th edition

divisions of a cobol program
Divisions of a Cobol Program
  • Identification Division
    • Identifies program to OS
    • Provides documentation
  • Environment Division
    • Defines files
    • Establishes Logical (program) and physical (computer) relationship
  • Data Division
    • Describes all input and output data
    • As well as scratch pad data (working storage)
  • Procedure Division
    • All the program logic

Structured COBOL Programming, Stern & Stern, 9th edition

slide50

Figure 1.6The First COBOL Program

Identification Division

1 IDENTIFICATION DIVISION.2 PROGRAM-ID. SENIOR.3 AUTHOR. ROBERT GRAUER.45 ENVIRONMENT DIVISION.6 INPUT-OUTPUT SECTION.7 FILE-CONTROL.8 SELECT STUDENT-FILE ASSIGN TO ‘A:\CHAPTR02\SENIOR.DAT’9 ORGANIZATION IS LINE SEQUENTIAL.10 SELECT PRINT-FILE11 ASSIGN TO PRINTER.1213 DATA DIVISION.14 FILE SECTION.15 FD STUDENT-FILE16 RECORD CONTAINS 43 CHARACTERS17 DATA RECORD IS STUDENT-IN.18 01 STUDENT-IN.19 05 STU-NAME PIC X(25).20 05 STU-CREDITS PIC 9(3).21 05 STU-MAJOR PIC X(15).22

Environment Division

Data Division

Structured COBOL Programming, Stern & Stern, 9th edition

slide51

Figure 1.6The First COBOL Program (continued)

Data Division

23 FD PRINT-FILE24 RECORD CONTAINS 132 CHARACTERS25 DATA RECORD IS PRINT-LINE. 26 01 PRINT-LINE PIC X(132).27 28 WORKING-STORAGE SECTION. 29 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.30 31 01 HEADING-FILE.32 05 FILLER PIC X(10) VALUE SPACES. 33 05 FILLER PIC X(12) VALUE ‘STUDENT NAME’.34 05 FILLER PIC X(110) VALUE SPACES.35 36 01 DETAIL-LINE. 37 05 FILLER PIC X(8) VALUE SPACES.38 05 PRINT-NAME PIC X(25). 39 05 FILLER PIC X(99) VALUE SPACES.40

Structured COBOL Programming, Stern & Stern, 9th edition

slide52

Figure 1.6The First COBOL Program (continued)

  • PROCEDURE DIVISION. 42 100-PREPARE-SENIOR-REPORT. 43 OPEN INPUT STUDENT-FILE 44 OUTPUT PRINT-FILE 45 READ STUDENT-FILE 46 AT END MOVE ‘NO’ TO DATA-REMAINS-SWITCH47 END-READ 48 PERFORM 200-WRITE-HEADING-LINE49 PERFORM 210-PROCESS-RECORDS50 UNTIL DATA-REMAINS-SWITCH = ‘NO’51 CLOSE STUDENT-FILE52 PRINT-FILE
  • 53 STOP RUN.54 55 200-WRITE-HEADING-LINE.56 MOVE HEADING-LINE TO PRINT-LINE57 WRITE PRINT-LINE.58 59 210-PROCESS-RECORDS.60 IF STU-CREDITS > 110 AND STU-MAJOR = ‘ENGINEERING’61 MOVE STU-NAME TO PRINT-NAME62 MOVE DETAIL-LINE TO PRINT-LINE63 WRITE PRINT-LINE64 END-IF
  • 65 READ STUDENT-FILE66 AT END MOVE ‘NO’ TO DATA-REMAINS-SWITCH67 END-READ.

Procedure Division

Structured COBOL Programming, Stern & Stern, 9th edition