Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED...

50
Structured COBOL Programm Structured COBOL Programm ing, Stern & Stern, 9th e ing, Stern & Stern, 9th e dition dition Chapter 1 Chapter 1 INTRODUCTION TO INTRODUCTION TO STRUCTURED PROGRAM STRUCTURED PROGRAM DESIGN IN COBOL DESIGN IN COBOL

Transcript of Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED...

Page 1: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Chapter 1Chapter 1

INTRODUCTION TO INTRODUCTION TO STRUCTURED PROGRAM STRUCTURED PROGRAM DESIGN IN COBOLDESIGN IN COBOL

Page 2: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

COMPUTER COMPUTER PROGRAMMING:PROGRAMMING:AN OVERVIEWAN OVERVIEW

Page 3: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Types of Computer ProgramsTypes of Computer Programs

COBOLCOBOL is one of the many is one of the many languageslanguages used to write used to write customized applications customized applications programs.programs.

Page 4: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Applications ProgramsApplications Programs

Interactive vs. Batch ProcessingInteractive vs. Batch Processing Interactive applicationsInteractive applications typically accept typically accept

input data from a PC, workstation, or input data from a PC, workstation, or terminal.terminal.

Batch ProcessingBatch Processing applications process applications process large volumes of input at periodic intervals.large volumes of input at periodic intervals.

Page 5: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Applications ProgramsApplications Programs

Applications programs that are written for a Applications programs that are written for a specific user are called specific user are called customized customized programsprograms..

Programs that are relatively standard are Programs that are relatively standard are application packagesapplication packages that might be that might be purchased.purchased.

Page 6: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

All programs executed by the computer All programs executed by the computer must be in must be in machine languagemachine language..

Machine Language ProgramsMachine Language Programs

Page 7: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Symbolic ProgramsSymbolic Programs

Symbolic Programs use English-Symbolic Programs use English-like or like or symbolicsymbolic instructionsinstructions..– These programs must be translated These programs must be translated

or compiled into machine language.or compiled into machine language.

– COBOL is a symbolic programming COBOL is a symbolic programming language used for commercial language used for commercial applications.applications.

Page 8: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

THE APPLICATIONS THE APPLICATIONS PROGRAM DEVELOPMENT PROGRAM DEVELOPMENT

PROCESSPROCESS

Page 9: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

PROGRAM DEVELOPMENT PROGRAM DEVELOPMENT PROCESSPROCESS

1. 1. Determine Program SpecificationsDetermine Program Specifications– Program SpecificationsProgram Specifications consist of the consist of the

following:following: Record layout formsRecord layout forms to describe the input and to describe the input and

outputoutput Printer spacing chartsPrinter spacing charts for printed output for printed output Screen layouts Screen layouts for interactive input/outputfor interactive input/output

Page 10: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

PROGRAM DEVELOPMENT PROCESSPROGRAM DEVELOPMENT PROCESS2. 2. Design the Program Using Program Design the Program Using Program

Planning Tools using Common Tools:Planning Tools using Common Tools:– FlowchartsFlowcharts

A block diagram providing a pictorial representation of the A block diagram providing a pictorial representation of the logic to be used in a programlogic to be used in a program

– PseudocodePseudocode English-like expressions to depict the logic of the programEnglish-like expressions to depict the logic of the program

– Hierarchy ChartsHierarchy Charts Charts showing relationships among sections in a Charts showing relationships among sections in a

programprogram

Page 11: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

PROGRAM DEVELOPMENT PROGRAM DEVELOPMENT PROCESSPROCESS

3. 3. Code and Enter the ProgramCode and Enter the Program

4. 4. Compile the ProgramCompile the Program– The COBOL compiler checks the source The COBOL compiler checks the source

code to insure there are no rule code to insure there are no rule violations. violations.

– A syntax error is a type of error that is A syntax error is a type of error that is found if a programming rule is violated.found if a programming rule is violated.

Page 12: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

PROGRAM DEVELOPMENT PROGRAM DEVELOPMENT PROCESSPROCESS

5. 5. Test the ProgramTest the Program– Programs are tested or Programs are tested or debuggeddebugged to to

ensure they have no errors.ensure they have no errors.– A A logic errorlogic error is a type of error that the is a type of error that the

programmer may find only when the programmer may find only when the program is tested with sample or test program is tested with sample or test data.data.

6. 6. Document the ProgramDocument the Program– Procedure manuals for users and Procedure manuals for users and

computer operators, called computer operators, called documentationdocumentation, , is prepared for use by the operating staff is prepared for use by the operating staff for regular production.for regular production.

Page 13: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

PROGRAM DEVELOPMENT PROGRAM DEVELOPMENT PROCESS PROCESS

************************************************************************************************ Remember, coding is undertaken only Remember, coding is undertaken only

afterafter the program requirements have been the program requirements have been fully specified and the logic has been fully specified and the logic has been carefully planned.carefully planned.

**************************************************************************************************

Page 14: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

DEBUGGING TECHNIQUESDEBUGGING TECHNIQUES Desk CheckingDesk Checking

– Reviewing the program before and after Reviewing the program before and after keyingkeying

Correcting Syntax ErrorsCorrecting Syntax Errors– Using the printed source list of the Using the printed source list of the

diagnostic messages to find and correct diagnostic messages to find and correct the errorsthe errors

Page 15: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

DEBUGGING TECHNIQUES DEBUGGING TECHNIQUES Program WalkthroughsProgram Walkthroughs

– Manually stepping through the program Manually stepping through the program with test data.with test data.

Detecting Logic Errors by Executing Detecting Logic Errors by Executing the Programthe Program– Often the most difficult part of debugging. Often the most difficult part of debugging. – The preparation of test data is an The preparation of test data is an

extremely critical aspect of debugging.extremely critical aspect of debugging.

Page 16: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

THE NATURE OF COBOLTHE NATURE OF COBOL COBOLCOBOL is a Business-Oriented is a Business-Oriented

LanguageLanguage– COBOL, is one of the most widespread COBOL, is one of the most widespread

commercial applications languages in use today.commercial applications languages in use today.

– COBOL COBOL is an abbreviation for is an abbreviation for COCOmmon mmon

BBusiness usiness OOriented riented LLanguage,anguage,

COBOL is a Standard LanguageCOBOL is a Standard Language– COBOL is a common programming language COBOL is a common programming language

available on most computers.available on most computers.

Page 17: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

THE NATURE OF COBOLTHE NATURE OF COBOL COBOL is an English-like LanguageCOBOL is an English-like Language

– All instructions can be coded using English All instructions can be coded using English words.words.

– The rules conform to many rules for writing in The rules conform to many rules for writing in EnglishEnglish

COBOL is a User-Friendly LanguageCOBOL is a User-Friendly Language– Because users are able to understand the Because users are able to understand the

English-like instructions it is considered a English-like instructions it is considered a user-friendly language.user-friendly language.

Page 18: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

THE FUTURE OF COBOLTHE FUTURE OF COBOL COBOL is likely to remain an important COBOL is likely to remain an important

language in the years ahead for three language in the years ahead for three reasons:reasons:1. Older, mainframe-based “legacy” systems 1. Older, mainframe-based “legacy” systems

will need to be maintained by maintenance will need to be maintained by maintenance programmers who know COBOL.programmers who know COBOL.

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

3. It is a very 3. It is a very efficientefficient language. language.

Page 19: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

QUESTIONS?!QUESTIONS?!

Page 20: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

1. A program must be in _________ 1. A program must be in _________ language to be executed or run.language to be executed or run.

Solution: machineSolution: machine

Page 21: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS2. Programs are typically written in a 2. Programs are typically written in a

_______ language rather than in _______ language rather than in machine language because machine language because __________.__________.

Solution: symbolic; Solution: symbolic;

machine languages are very complexmachine languages are very complex

Page 22: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

3. Programs written in a language other than 3. Programs written in a language other than machine language must be _______ before machine language must be _______ before execution can occur.execution can occur.

Solution: translated or compiledSolution: translated or compiled

Page 23: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

4. The process of converting a source 4. The process of converting a source program into machine language is called program into machine language is called ___________.___________.

Solution: compilation or translationSolution: compilation or translation

Page 24: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

5. The program written in a programming 5. The program written in a programming language such as COBOL is called the language such as COBOL is called the ________ program.________ program.

Solution: source or applicationsSolution: source or applications

Page 25: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

6. The object program is the _______.6. The object program is the _______.

Solution: set of instructions that has been Solution: set of instructions that has been converted into machine languageconverted into machine language

Page 26: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

7. A ______ converts a source program into 7. A ______ converts a source program into a(n)_____ program.a(n)_____ program.

Solution: compiler or translator program: Solution: compiler or translator program: object or machine languageobject or machine language

Page 27: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

8. The errors that are detected during 8. The errors that are detected during compilation denote ______; they are compilation denote ______; they are usually referred to as ________ usually referred to as ________ errors.errors.

Solution: any violation of programming Solution: any violation of programming rules in the use of the symbolic rules in the use of the symbolic programming language; syntaxprogramming language; syntax

Page 28: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

9. Before executing a program with test data, 9. Before executing a program with test data, the logic of the program can be checked the logic of the program can be checked manually using a technique called a manually using a technique called a ____________.____________.

Solution: program walkthroughSolution: program walkthrough

Page 29: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

10. COBOL is an abbreviation10. COBOL is an abbreviation

for _________.for _________.

Solution: Common Business Oriented Solution: Common Business Oriented LanguageLanguage

Page 30: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SELF-TEST QUESTIONSSELF-TEST QUESTIONS

11. COBOL is a common language in the 11. COBOL is a common language in the sense that ______.sense that ______.

Solution: it can be used on many computersSolution: it can be used on many computers

Page 31: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

TECHNIQUES FOR TECHNIQUES FOR IMPROVING PROGRAM IMPROVING PROGRAM

DESIGNDESIGN

Page 32: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Structured Programming Using Structured Programming Using Modular Design for Coding Modular Design for Coding

ParagraphsParagraphs The most important technique for The most important technique for

improving the design of a program in improving the design of a program in any language is called any language is called structured structured programming.programming.

Structured ProgrammingStructured Programming is a is a technique using logical control technique using logical control constructs that make programs easier constructs that make programs easier to read, debug, and modify if changes to read, debug, and modify if changes are required.are required.

Page 33: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Structured Programming Using Structured Programming Using Modular Design for Coding Modular Design for Coding

ParagraphsParagraphs Structured programming is often called Structured programming is often called

GO-TO-less programming since GO-TO-less programming since programmatic branches programmatic branches do not usedo not use GO TO statements.GO TO statements.

In COBOL this means writing In COBOL this means writing programs using programs using PERFORMPERFORM statementsstatements

Page 34: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

Structured Programming Using Structured Programming Using Modular Design for Coding Modular Design for Coding

ParagraphsParagraphs

The typicalThe typical structured structured program is divided intoprogram is divided into paragraphsparagraphs or or modulesmodules, where a main , where a main module calls in other modules as needed.module calls in other modules as needed.– Each module can be tested independently.Each module can be tested independently.

Paragraph, routine, module are used interchangeably Paragraph, routine, module are used interchangeably

Page 35: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

The Top-Down Approach for The Top-Down Approach for Coding ModulesCoding Modules

Proper designProper design is best achieved by is best achieved by developing developing major modulesmajor modules before before minor minor onesones..

Main routinesMain routines are coded first and are are coded first and are followed by followed by intermediateintermediate routines and routines and then then minorminor ones. ones.

Page 36: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

The Top-Down Approach The Top-Down Approach

Coding using the Coding using the top-down manner top-down manner gives gives the primary attention to the origination of the the primary attention to the origination of the program.program.

Details are deferred or saved for minor Details are deferred or saved for minor modules, which are modules, which are coded last.coded last.

Page 37: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

A BRIEF OVERVIEW OF A BRIEF OVERVIEW OF PROGRAM PLANNING PROGRAM PLANNING

TOOLSTOOLS

Page 38: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

RULES FOR INTERPRETING RULES FOR INTERPRETING PSEUDOCODEPSEUDOCODE

1. A 1. A pseudocodepseudocode begins with a begins with a STARTSTART and and ends with a ends with a STOPSTOP..

2. All instructions are 2. All instructions are readread in sequence. in sequence.

3. The instructions between the:3. The instructions between the:PERFORM...END-PERFORMPERFORM...END-PERFORM are executed are executed repeatedly repeatedly UNTILUNTIL there are no more records there are no more records to process.to process.

Page 39: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

100-MAINMODULE

200-WAGEROUTINE

HIERARCHY OR STRUCTURE HIERARCHY OR STRUCTURE CHARTCHART

Structure chartsStructure charts identify identify WHATWHAT each each module does, and how it relates to other module does, and how it relates to other modules.modules.– The following chart shows the relationships The following chart shows the relationships

among modules in a program: among modules in a program:

Page 40: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

CHAPTER SLIDES END HERECHAPTER SLIDES END HERE

CHAPTER SUMMARY CHAPTER SUMMARY COMES NEXTCOMES NEXT

Page 41: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

CHAPTER SUMMARYCHAPTER SUMMARYA. The Nature of COBOLA. The Nature of COBOL

1. It is the most widespread commercial 1. It is the most widespread commercial programming language in use today.programming language in use today.

2. COBOL is the abbreviation for Common 2. COBOL is the abbreviation for Common Business Oriented Language.Business Oriented Language.

3. It is an English-like language.3. It is an English-like language.

Page 42: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYB. Program Preparation and DebuggingB. Program Preparation and Debugging

1.1. Get program specifications from the Get program specifications from the analyst or prepare them yourself.analyst or prepare them yourself.

2.2. Use planning tools--flowcharts, pseudocode, Use planning tools--flowcharts, pseudocode, hierarchy charts--for program design.hierarchy charts--for program design.

3.3. Code the program.Code the program.4.4. Compile the program and fix syntax errors.Compile the program and fix syntax errors.5.5. Test the program using debugging techniques.Test the program using debugging techniques.6.6. Document the program.Document the program.

Page 43: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYC. Techniques for Improving Program C. Techniques for Improving Program

DesignDesign1. Structured Programming1. Structured Programming

a. Referred to as GO-TO-less programminga. Referred to as GO-TO-less programmingb. Structured programs are subdivided into b. Structured programs are subdivided into

modules or paragraphs.modules or paragraphs.

2. Top-Down Programming2. Top-Down Programminga. Major modules are coded before minor a. Major modules are coded before minor

ones.ones.B. Similar to developing an outline before B. Similar to developing an outline before

writing a report.writing a report.

Page 44: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYD. The COBOL DivisionsD. The COBOL DivisionsIdentification DivisionIdentification Division

a. Identifies the program to the computer a. Identifies the program to the computer system.system.

b. May provide some documentation as well.b. May provide some documentation as well.c. c. PROGRAM-IDPROGRAM-ID is the only required entry. is the only required entry.

Environment DivisionEnvironment Division– Assigns a file-name to each file used.Assigns a file-name to each file used.– Specifies the device that the file will use.Specifies the device that the file will use.

Page 45: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYData Division Data Division

a. Defines & describes all input, output & work a. Defines & describes all input, output & work area area

b. b. File-SectionFile-Section(1) Each file-name is described in an (1) Each file-name is described in an FDFD..(2) Each record format within every file is an 01 (2) Each record format within every file is an 01

entry.entry.(3) Record fields are described with a PICTURE (3) Record fields are described with a PICTURE

clause that specifies the size & type.clause that specifies the size & type.

c. c. Working-Storage SectionWorking-Storage Section(1) Defines work areas (1) Defines work areas (2) An end-of-file indicator is coded here.(2) An end-of-file indicator is coded here.

Page 46: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYCOBOL DIVISIONSCOBOL DIVISIONS

Procedure DivisionProcedure Divisiona. Subdivided into paragraphs or a. Subdivided into paragraphs or

modules.modules.b. Includes all instructions to process b. Includes all instructions to process

input and produce output.input and produce output.c. All instructions are executed c. All instructions are executed

sequence.sequence.PERFORM...UNTIL... END-PERFORMPERFORM...UNTIL... END-PERFORM is a is a

loop.loop.

Page 47: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYProcedure DivisionProcedure Division

c. All instructions are executed c. All instructions are executed sequence, unless there is a loop sequence, unless there is a loop such assuch as PERFORM UNTIL... PERFORM UNTIL... … ….... … …....

END-PERFORMEND-PERFORM

Page 48: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARY

Procedure DivisionProcedure Divisiond. Main-module entries:d. Main-module entries:

– The following are typical entries in a The following are typical entries in a main module:main module:(1) Files are either (1) Files are either INPUTINPUT or or OUTPUTOUTPUT

and activated in an and activated in an OPENOPEN statement. statement.

(2) A (2) A PERFORM...PERFORM... …. …. END-PERFORM END-PERFORM is a loop that is is a loop that is executed until there are no more records.executed until there are no more records.

Page 49: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYMain-module entries (continued):Main-module entries (continued):

(3)(3)Within the Within the PERFORM PERFORM we often code a we often code a READREAD...... AT ENDAT END...... NOT AT ENDNOT AT END…… END-READEND-READ..

(4) A (4) A CLOSECLOSE statement deactivates all statement deactivates all files.files.

(5) (5) STOP RUNSTOP RUN ends processing. ends processing.

Page 50: Structured COBOL Programming, Stern & Stern, 9th edition Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.

Structured COBOL Programming,Structured COBOL Programming, Stern & Stern, 9th edition Stern & Stern, 9th edition

SUMMARYSUMMARYe. Calculation or processing paragraphse. Calculation or processing paragraphs

(1) These paragraphs are executed when a (1) These paragraphs are executed when a statement in the main module specifies a statement in the main module specifies a PERFORMPERFORM paragraph name. paragraph name.

(2) For example, logic for processing an input (2) For example, logic for processing an input record may be contained in one or more record may be contained in one or more paragraphs.paragraphs.