COP 2121 Program Development Process
Contents
Program Development Process
Program Specifications
- System analysts, users, and programmers develop specifications
- Specifications include:
- Description of input and output data
- Step-by-step processing required to convert input to output
Record layout forms describe format of input and output data
- Data names of each data item in record
- Location of each data item in record
- Size of each data item
- Number of decimal positions (for numerica data items)
Design the program
Program planning tools used to map out structure and logic of program
- Flowcharts use block diagrams to represent logic
- Pseudocode uses English-like statements
- Hierarchy charts show relationships among sections of program
Improving Program Design
Two techniques used to develop programs that are easier to understand, test, debug, and modify
- Structured Programming
- Top-Down programming
Structured Programming
Program divided into paragraphs
- Main paragraph or module control logic flow using PERFORM statements
- Main module "performs" other modules when instructions in that module are required
- Each module can be written and tested independently of others
Top-Down Programming
For COBOL program
- Code main modules or routines first
- Code intermediate modules next
- Details deferred to minor modules and coded last
Code and Enter Program
- Programmer writes and enters program into computer
- Program written in symbolic language (like COBOL)
- Called source program
Compile Source Program
Compiler is program that
- Checks source program for rule violations
- Translates source program into object program
Test Program
- Test or debug program to ensure it contains no errors
- Check for two types of errors
- Compile-time errors
- Execution errors
Compile-Time Errors
- Errors detected by compiler during translation from COBOL to machine language
- Detects violations of programming rules
- Misspelled reserved words
- Missing punctuation
- Also called syntax errors
Execution Errors
- Detected when program is run
- Logic error causes incorrect output
- Sequence of instructions incorrect
- Wrong instruction coded
- Run-time error if computer cannot execute instruction
- Attempt to divide by zero
- Attempt to read a file that cannot be found
Debugging Techniques
- Desk checking
- Correcting syntax errors
- Program walkthroughs
- Executing the program
Document the Program
- Documentation - formal set of procedures and instructions to specify how to use program
- Written for:
- Those working with output
- Computer operators who run program
- Maintenance programmers who make modifications to program
Sample COBOL Program
IDENTIFICATION DIVISION. PROGRAM-ID. WAGESBATCH. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EMPLOYEE-DATA ASSIGN TO “/home/seemab/EMP-DAT.in". SELECT PAYROLL-LISTING ASSIGN TO “/home/seemab/EMP-OUT-DAT.out". DATA DIVISION. FILE SECTION. FD EMPLOYEE-DATA. 01 EMPLOYEE-RECORD. 05 EMPLOYEE-NAME-IN PIC X(20). 05 HOURS-WORKED-IN PIC 9(2). 05 HOURLY-RATE-IN PIC 9V99. FD PAYROLL-LISTING. 01 PRINT-REC. 05 PIC X(20). 05 NAME-OUT PIC X(20). 05 PIC X(10). 05 HOURS-OUT PIC 9(2). 05 PIC X(8). 05 RATE-OUT PIC 9.99. 05 PIC X(10). 05 WEEKLY-WAGES-OUT PIC 999.99. WORKING-STORAGE SECTION. 01 ARE-THERE-MORE-RECORDS PIC XXX VALUE "YES". PROCEDURE DIVISION. 100-MAIN. OPEN INPUT EMPLOYEE-DATA OUTPUT PAYROLL-LISTING PERFORM UNTIL ARE-THERE-MORE-RECORDS = "NO" READ EMPLOYEE-DATA AT END MOVE 'NO ' TO ARE-THERE-MORE-RECORDS NOT AT END PERFORM 200-WAGE-ROUTINE END-READ END-PERFORM CLOSE EMPLOYEE-DATA PAYROLL-LISTING STOP RUN. 200-COMPUTE-WAGE-ROUTINE. MOVE SPACES TO PRINT_REC MOVE EMPLOYEE-NAME-IN TO NAME-OUT MOVE HOURS-WORKED-IN TO HOURS-OUT MOVE HOURLY-RATE-IN TO RATE-OUT MULTIPLY HOURLY-RATE-IN BY HOURS-WORKED-IN GIVING WEEKLY-WAGES-OUT WRITE PRINT-REC.