Understanding the Mainline Logical Flow Through a Program (continued) - PowerPoint PPT Presentation

About This Presentation
Title:

Understanding the Mainline Logical Flow Through a Program (continued)

Description:

Title: Programming Logic and Design Fourth Edition, Introductory Created Date: 9/27/2002 11:29:22 PM Document presentation format: On-screen Show – PowerPoint PPT presentation

Number of Views:80
Avg rating:3.0/5.0
Slides: 28
Provided by: mfulcherC
Category:

less

Transcript and Presenter's Notes

Title: Understanding the Mainline Logical Flow Through a Program (continued)


1
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

2
Understanding the Mainline Logical Flow Through a
Program (continued)
3
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

4
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

5
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

6
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

7
Declaring Variables (continued)
  • Can use variables for report headings
  • Embed any required spaces
  • Heading can be printed using these variables

8
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

9
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

10
Printing Headings
  • Printing headings for reports usually is done at
    beginning of the program or possibly for each new
    page

11
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

12
Reading the First Input Record (continued)
  • Interactive input (from a keyboard)

13
Reading an Input Record
  • Input from a data file

14
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

15
Checking for End of File (continued)
16
Modules, Subroutines, Procedures, Functions, or
Methods
  • Module
  • Unit of code that performs one small task
  • Called a subroutine, procedure, function, or
    method
  • Modularization breaking a large program into
    modules

17
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

18
Modularization Provides Abstraction
  • 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

19
Modularization Provides Abstraction (continued)
  • A To-Do list
  • with abstraction without abstraction

20
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

21
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

22
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

23
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

24
Modularizing a Program (continued)
25
Modules Calling Other Modules
26
Understanding Documentation
  • 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

27
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
Write a Comment
User Comments (0)
About PowerShow.com