Understanding the Mainline Logical Flow Through a Program (continued)

Slides:



Advertisements
Similar presentations
Chapter 3: Modules, Hierarchy Charts, and Documentation
Advertisements

Chapter 3: Modularization
Chapter 2: Modularization
Modules, Hierarchy Charts, and Documentation
Programming Logic and Design Fourth Edition, Introductory
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Programming Logic and Design, Third Edition Comprehensive
Programming Logic and Design Fourth Edition, Introductory
ITEC113 Algorithms and Programming Techniques
Program Design and Development
Writing a Complete Program
Chapter 2: Input, Processing, and Output
Modules, Hierarchy Charts, and Documentation
Guide To UNIX Using Linux Third Edition
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Pseudocode.
Chapter 3 Planning Your Solution
Programming Logic and Design Fourth Edition, Introductory
The Program Design Phases
- Meeting 4 – Writing a Complete Program
CS102 Introduction to Computer Programming
Programming Logic and Design Fifth Edition, Comprehensive
Structured COBOL Programming, Stern & Stern, 9th edition
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
CIS Computer Programming Logic
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
Programming Logic and Design Fifth Edition, Comprehensive
Input, Output, and Processing
Programming Logic and Design Sixth Edition Chapter 5 Looping.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
6 Chapter 61 Looping Programming Logic and Design, Second Edition, Comprehensive 6.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 6 Looping.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Programming Logic and Design Seventh Edition
What is Programming? A program is a list of instructions that is executed by a computer to accomplish a particular task. Creating those instructions is.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
The Hashemite University Computer Engineering Department
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Topics Designing a Program Input, Processing, and Output
Key Ideas from day 1 slides
Chapter 2: Input, Processing, and Output
DDC 1023 – Programming Technique
Programming Logic and Design Fourth Edition, Comprehensive
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Designing and Debugging Batch and Interactive COBOL Programs
Constant: value does not change
Programming Logic and Design Fourth Edition, Comprehensive
Topics Introduction to Functions Defining and Calling a Void Function
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Data Groupings: File File: a group of related records
Writing a Complete Program
Topics Introduction to Functions Defining and Calling a Function
Chapter 2: Input, Processing, and Output
Modules, Subroutines, Procedures, Functions, or Methods
Chapter 4: Writing and Designing a Complete Program
Programming Logic and Design Eighth Edition
Presentation transcript:

Understanding the Mainline Logical Flow Through a Program (continued) Procedural program: one procedure follows another from beginning to end Mainline logic has three distinct parts: Housekeeping: steps to get ready Main loop: instructions executed for every input record End-of-job: steps taken at end of program Break the logic down into at least three modules Programming Logic and Design, Introductory, Fourth Edition

Understanding the Mainline Logical Flow Through a Program (continued) Programming Logic and Design, Introductory, Fourth Edition

Understanding the Mainline Logical Flow Through a Program (continued) Modularization of the program: Keeps the job manageable Allows multiple programmers to work simultaneously Keeps the program structured Programming Logic and Design, Introductory, Fourth Edition

Housekeeping Tasks Housekeeping tasks: include all steps that occur at the beginning of the program Declare variables Open files Perform one-time-only tasks such as printing headings Read the first input record Programming Logic and Design, Introductory, Fourth Edition

Declaring Variables Assign identifiers to memory locations Specify the name and data type Use meaningful names and follow standards Prefixes may be used to group related variables Declare a variable for each field in a data file Programming Logic and Design, Introductory, Fourth Edition

Declaring Variables (continued) Initializing (or defining) the variable: providing an initial value Some languages provide default initial values Other languages leave variables with an unknown or garbage value Variables representing data fields in files do not need to be initialized Programming Logic and Design, Introductory, Fourth Edition

Declaring Variables (continued) Can use variables for report headings Embed any required spaces Heading can be printed using these variables Programming Logic and Design, Introductory, Fourth Edition

Declaring Variables (continued) Local variables: declared within a module Global variables: declared at the beginning of the program, and used in all modules Annotation box: flowchart symbol containing notes Data Dictionary: list of variables used in a program, with their type, size, and description Programming Logic and Design, Introductory, Fourth Edition

Opening Files Specify file name and path (location) Issue a file open command If no input file is opened, input may be accepted from the standard input device (e.g., keyboard) You must open both input and output files to be used, including printer output device If no output file is opened, standard output device (e.g., monitor) may be used Programming Logic and Design, Introductory, Fourth Edition

Printing Headings Printing headings for reports usually is done at beginning of the program or possibly for each new page Programming Logic and Design, Introductory, Fourth Edition

Reading an Input Record Reading the first input record is the last housekeeping task Interactive application: Interacts with users via keyboard or mouse input Program pauses when the read command is executed until the user enters data Delimiter: a character designated as a separator between data values Prompt: an output statement that asks the user to enter specific data Programming Logic and Design, Introductory, Fourth Edition

Reading the First Input Record (continued) Interactive input: (from a keyboard) Programming Logic and Design, Introductory, Fourth Edition

Reading an Input Record Input from a data file: Programming Logic and Design, Introductory, Fourth Edition

Checking for the End of the File After reading a file For an interactive program, EOF may be determined when: User enters a predetermined sentinel value User selects a screen option using a mouse For input from a file, the input device recognizes EOF EOF may occur on the first read If there is data, each record is processed before the next read occurs Programming Logic and Design, Introductory, Fourth Edition

Checking for End of File (continued) Programming Logic and Design, Introductory, Fourth Edition

Modules, Subroutines, Procedures, Functions, or Methods Unit of code that performs one small task Called a subroutine, procedure, function, or method Modularization: breaking a large program into modules Programming Logic and Design, Introductory, Fourth Edition

Modules, Subroutines, Procedures, Functions, or Methods (continued) Advantages of modularization: Provides abstraction Allows multiple programmers to work simultaneously Allows code reuse Makes identifying structures easier Programming Logic and Design, Introductory, Fourth Edition

Modularization Provides Abstraction Focusing on important properties while ignoring non-essential details Avoids the low-level details and uses a high-level approach Makes complex tasks look simple Programming Logic and Design, Introductory, Fourth Edition

Modularization Provides Abstraction (continued) A To-Do list with abstraction: without abstraction: Programming Logic and Design, Introductory, Fourth Edition

Modularization Allows Multiple Programmers to Work on a Problem Large programming projects can be divided into modules Modules can be written by different programmers Development time is significantly reduced Programming Logic and Design, Introductory, Fourth Edition

Modularization Allows You to Reuse Your Work Reusability: the ability to use modules in a variety of applications Reliability: assurance that a module has been tested and proven to function correctly Programming Logic and Design, Introductory, Fourth Edition

Modularizing a Program Most programs contain a main module Contains the mainline logic Accesses other modules or subroutines Rules for module names used here: Must be one word Should be meaningful Are followed by a set of parentheses Programming Logic and Design, Introductory, Fourth Edition

Modularizing a Program (continued) Calling program (or calling module): one that uses another module Flowchart symbol for calling a module: a rectangle with bar across the top Flowchart for the module contains: Module name in the start symbol exit or return in the stop symbol When a module is called, logic transfers to the model When module ends, logic transfers back to the caller Programming Logic and Design, Introductory, Fourth Edition

Modularizing a Program (continued) Programming Logic and Design, Introductory, Fourth Edition

Modules Calling Other Modules Programming Logic and Design, Introductory, Fourth Edition

Understanding Documentation All supporting material that goes with a program Two major categories: for users and for programmers Usually created by system analysts and/or tech writers May be printed or electronic (Web or CD) End users: people who use computer programs Program Documentation: Internal program documentation: comments within code External program documentation: supporting paperwork written before programming begins Programming Logic and Design, Introductory, Fourth Edition

Completing the Documentation Program documentation may contain: Output design Input description Flowcharts Pseudocode Program code listing User documentation may contain Manuals Instructional material Operating instructions Programming Logic and Design, Introductory, Fourth Edition