1 / 23

Introductory Remarks

Introductory Remarks. COURSE OBJECTIVES: (TAKEN FROM PREFACE) 1. To teach students how to design programs so that they are easy to read, debug, adapt, and maintain. 2. To provide students with the ability to write well-designed elementary and intermediate structured COBOL programs

Download Presentation

Introductory Remarks

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introductory Remarks

  2. COURSE OBJECTIVES: (TAKEN FROM PREFACE) 1. To teach students how to design programs so that they are easy to read, debug, adapt, and maintain. 2. To provide students with the ability to write well-designed elementary and intermediate structured COBOL programs 3. To familiarize students with information processing and systems concepts that will help them interact with users and systems analysts when designing programs; 4. To focus on the key elements of the most recent cobol standards that facilitate and promote the writing of well-designed structured programs. 5. To familiarize students with programming tools such as pseudo-code and hierarchy charts that make program logic more structured, modular, and top-down

  3. FEATURES OF THE TEXT • Each chapter starts with A detailed chapter outline, and A list of objectives. • Each chapter contains many self-tests (and solutions) for self-examination. It is real important that you take these, as some of the test questions may come from these questions within the chapters. • 3. Be sure to understand the key terms, and study the debugging exercises. Note that the programming assignments at the end of the chapter are in increasingly order of complexity.

  4. AN INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL • TYPES OF COMPUTER PROGRAMS • A program is a set of instructions that enable a computer to process data. • Operating system programs (systems software) - control the operations of the computer - such as overseeing the operations, providing input-output, managing memory, devices, processors, etc.; Operating systems programs (or systems software) also includes utility routines that assist system as well as application programmers, such as copy, format, dir, etc. • Applications programs - perform tasks required by users - e.g., Payroll programs. (Functional programs) • Software - a term used to describe all types of programs.

  5. Applications Program • An applications program takes input data manipulates it (processes the data) and produces Output data. • Therefore, we have the basic process: input - process - output • Example: given data of hours worked, rate of pay: compute pay • Input data: 1)number of hours, say 40, and • 2)pay rate, say, 7.50 • The Process is to take this data and multiply the two numbers to produce a product. To do this, we write a "payroll program" (pretty simple here, of course), that contains instructions to take (read, retrieve) two numbers and multiply them together to produce the product. • Output data is the product, or, $30.00.

  6. Custom Program Such an example is typical of applications programs and are written by ‘applications programmers.’ If an applications programmer were to take a general capability, such as a payroll program, and tailor it to a specific user's need, then we are said to tailor or customize the program. Example:a specific user of a standard payroll program may afford his/her employees some unique benefits, such as profit sharing or buying a bond a month from his/her check, for example. Another user may not. So to customize a payroll program (clearly a very simple example), an applications programmer might be required to add instructions in the program that subtracts $50.00 from an employees gross pay before calculating federal tax. This program is now tailored (or customized) to this users requirements.

  7. Higher Level Languages • Higher-level languages. COBOL, Fortran, Ada, C, Java, and others are said to be higher level languages, because they tend to be English-like - to a greater or lesser degree. • Machine Language. • Computer can only understand sequences of zeroes and ones, which is called machine language. • For the computer to understand your COBOL program, your program must be translated from what you write into something that the machine can understand. • The conversion from your "source program" into the machine language is called compilation (generically, ‘translation’), and a compiler (an example of a ‘systems program’) provides the translation for you.

  8. Versions of Cobol History Department of Defense IBM - PL/1 Cobol 68, 74, 85, 2002, etc.

  9. THE PROGRAM DEVELOPMENT PROCESS • Requirements must be specified and understood. (Analysis) • . A ‘structured solution’ must be created from the specifications accompanied by a careful set of detailed procedures (that is, the logic) must be developed. This is the solution. (Design) • . Then, the design must be implemented in code (Programming) • . Then, after (and during) the coding itself, considerable testing must take place - at various levels. (Testing) • . The program(s) must then be installed in user environment. (Installation) • . Many other tasks are not included here such as Documentation • User training, Follow on maintenance, and much more. • . Let's look at each of these.

  10. Specifications . After analyzing requirements, the business analyst or a system analyst working with the user, will write the software specifications. . Specifications (among many other things) contain (typically) the 1. Input data formats (data items and their characteristics.) 2. Outputs required (updated master file; printed reports, ... 3. Narrative (this can take on many forms) Text, models, decision tables, and combinations. Note: input - process - output (again) These are the ‘whats’ of the application. Typical kinds of data...

  11. Data Hierarchy • File: a collection of ‘records’ that serve as input or output to a program. e.g. An employee file, an inventory file… • Can be ‘organized’ and ‘accessed’ in many ways. • Record: a collection of related ‘fields’ (data items) normally related and forming a group of items that relate to the subject at hand. • e.g. An inventory record for a specific item in stock might contain fields such as: • Stock number; Nomenclature; Unit cost; Reorder point; Quantity on hand, and more. • Field: a collection of ‘characters,’ ‘numbers,’ etc. Such as a pay-rate, a name, an address, a ssan, etc.

  12. Data Hierarchy File Record Field Character: (byte) a single character: alphabetic (letters of the alphabet and space), numeric, alphanumeric, special characters (e.g. For data transmission), non-printing characters, and more. Bit (contraction of binary digit) a ‘1’ or ‘0’ that represents a ‘state’ - on/off; yes/no; true/false, etc. Characters are composed of numbers of bits - usually seven or eight. Character set: EBCDIC; ASCII ; others. (Much more later)

  13. Input and Output Specifications Normally contain: 1. Record layout forms - normally the typical input or output data descriptions. (See textbook) . Record layouts indicate data items (fields) within each record; . Location of items within record, size, numeric, positions, fractional positions. . (Empnum, reghrs, others, rate, code) 2. Printer Layout Charts . report headers, column headers, precise print positions for the computed / printed output (detail lines); any summary or total lines, report numbers, page numbers,… . Menus and menu layouts; hierarchy of menus. . GUIs may be specified.

  14. Design Architectural design Preliminary design External design Discussed earlier Building blocks Modules of application Structure charts All components of the application. Detail design Internal design Algorithm design The details of each module in application.

  15. Detail (Program) design . This is program design (algorithmic design) . Must plan your logic. (Program blueprint) . Planning tools .. Flowcharts .. Pseudo code .. Hierarchy charts Program Flowchart - conventional block diagram . Shows the flow of logic (control) in a module Sequence Selection Iteration Pseudo-code - English-like statements (textual) Used for modeling logic Careful conventions Indentation

  16. Language independence Modeling an algorithm - the thinking!! Program flowcharts . Graphical language . Used for modeling logic . Indented; careful conventions and symbols . Language independence . Used to model the algorithm Modeling the algorithm (design) is modeling a solution to problem from the problem space (Specifications) Hierarchy charts (HIPO) - Hierarchy plus input process output . Show relationships between parts of a program . Show dependencies . Specifically divide all activities into inputs, or outputs or processes. . Show specifically which inputs are needed by which processes to produce specific outputs.

  17. Programming . Using the program logic shown via design, a programmer writes instructions (source program) in a source language (here, source language is Cobol.) . Must be translated to machine language for computer to understand. (Translated / compiled) . All programmer-created source language statements are built one at a time on disk and are entered into the computer via some kind of editor. . After the entire program is entered, we must now compile the source program.

  18. SOURCE LANGUAGES TO DO: ab=c Fortran: c = a*b COBOL: Multiply A BY B GIVING C C and Java: c = a*b; Assembler: (IBM Mainframe): L 5,A M 4,B ST 5,C Higher level languages............ Source Program: (HLL) Fortran, Cobol, C, PL/1, Pascal, Java, C, Ada, ... Assembler Languages - One to one w/machine language instructions Characteristics... Translators = compilers, assemblers, "interpreters"

  19. TESTING THE PROGRAM 1. Syntax errors - compilation process. (Clean compile) (95% done? Really, 10% done!) 2. Logic errors - execution process - runs your program. The ‘real’ problems to debug Examples: 1. Comma versus period; misspell keyword; filename referred to not found... 2. Add instead of Multiply. . Program may or may not still run - but not correctly . May still go to EOJ!!! 3. Executing correctly-stated statements but not in the correct ‘order’ to get the job done. . Can be difficult to find. Eliminating compilation / execution (syntax / logic) errors is the norm. Called debugging!! This is really how one learns the language: program, program, program; make errors; learn.

  20. IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EMPLOYEE-DATA ASSIGN TO “C:\COP2120\P4\JoeSchmuck\indata.txt”. SELECT PAY-LISTING ASSIGN TO “C:\COP2120\P4/JoeSchmuck\report.txt”. DATA DIVISION. FILE SECTION. FD EMPLOYEE-DATA LABEL RECORDS STANDARD. 01 EMPLOYEE-RECORD. 05 EMPLOYEE-NAME-IN PIC X(20). 05 HOURS-WORKED-IN PIC 99. 05 HOURLY-RATE-IN PIC 9V99. FD PAYROLL-LISTING LABEL RECORDS ARE OMITTED. 01 PRINT-REC. 05 FILLER* PIC X(20). 05 NAME-OUT PIC X(20). 05 PIC X(10). 05 HOURS-OUT PIC 99. 05 PIC X(8). 05 RATE-OUT PIC 9.99. 05 PIC XXXXXX. 05 WEEKLY-WAGES-OUT PIC 999.99. WORKING-STORAGE SECTION. 01 ARE-THERE-MORE-RECS PIC XXX VALUE ‘YES’.

  21. PROCEDURE DIVISION. 100-MAIN-MODULE. OPEN INPUT EMPLOYEE-DATA OUTPUT PAYROLL-LISTING. READ EMPLOYEE-DATA AT END MOVE ‘NO’ TO ARE-THERE-MORE-RECS END-READ. PERFORM 200-WAGE-ROUTINE UNTIL ARE-THERE-MORE-RECS = ‘NO’. CLOSE EMPLOYEE-DATA PAYROLL-LISTING. STOP RUN. 200-WAGE-ROUTINE. MOVE SPACES TO PRINT-REC. MOVE EMPLOYEE-NAME-IN TO NAME-OUT. MOVE HOURS-WORKED TO HOURS-OUT. MOVE HOURLY-RATE-IN TO RATE-OUT. MULTIPLY HOURS-WORKED-IN BY HOURLY-RATE-IN GIVING WEEKLY-WAGES-OUT. WRITE PRINT-REC. READ EMPLOYEE-DATA AT END MOVE ‘NO’ TO ARE-THERE-MORE-RECS END-READ.

  22. MUCH TO SAY.... . Divisions, section, paragraphs, ‘areas.’ . Input ‘formats’ output ‘formats’ . See size and classification of data . Input/output descriptions: movement of data . Choices of data names; standards. . Formatting standards . Internal documentation . Value clauses

  23. COBOL PROGRAM FLOWCHART FOR SAMPLE PROGRAM

More Related