Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Logic and Design Fourth Edition, Introductory Chapter 3 Modules, Hierarchy Charts, and Documentation.

Similar presentations


Presentation on theme: "Programming Logic and Design Fourth Edition, Introductory Chapter 3 Modules, Hierarchy Charts, and Documentation."— Presentation transcript:

1 Programming Logic and Design Fourth Edition, Introductory Chapter 3 Modules, Hierarchy Charts, and Documentation

2 Programming Logic and Design, Introductory, Fourth Edition2 Objectives Describe the advantages of modularization Modularize a program Understand how a module can call another module Explain how to declare variables Create hierarchy charts

3 Programming Logic and Design, Introductory, Fourth Edition3 Objectives (continued) Understand documentation Design output Interpret file descriptions Understand the attributes of complete documentation

4 Programming Logic and Design, Introductory, Fourth Edition4 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

5 Programming Logic and Design, Introductory, Fourth Edition5 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

6 Programming Logic and Design, Introductory, Fourth Edition6 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

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

8 Programming Logic and Design, Introductory, Fourth Edition8 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

9 Programming Logic and Design, Introductory, Fourth Edition9 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

10 Programming Logic and Design, Introductory, Fourth Edition10 Modularization Makes It Easier to Identify Structures Combining several tasks into modules may make it easier for beginning programmers to: –Determine if a program is structured –Identify structures in a program Experienced programmers modularize for abstraction, ease of dividing the work, and reusability

11 Programming Logic and Design, Introductory, Fourth Edition11 Modularization Makes It Easier to Identify Structures (continued) Is this structured?

12 Programming Logic and Design, Introductory, Fourth Edition12 Modularization Makes It Easier to Identify Structures (continued)

13 Programming Logic and Design, Introductory, Fourth Edition13 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

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

15 Programming Logic and Design, Introductory, Fourth Edition15 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 module When module ends, logic transfers back to the caller

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

17 Programming Logic and Design, Introductory, Fourth Edition17 Modules Calling Other Modules

18 Programming Logic and Design, Introductory, Fourth Edition18 Modules Calling Other Modules (continued) Knowing when to break a module into its own subroutines or submodules is an art Best practice: place together statements that contribute to one specific task Functional cohesion: extent to which the statements contribute to the same task

19 Programming Logic and Design, Introductory, Fourth Edition19 Declaring Variables Declaring a variable involves: –Providing a name for the memory location where the value will be stored –Specifying the type of the data Data types used here: –num for number values –char for all other values Where and when a variable must be declared is language-dependent

20 Programming Logic and Design, Introductory, Fourth Edition20 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

21 Programming Logic and Design, Introductory, Fourth Edition21 Declaring Variables (continued)

22 Programming Logic and Design, Introductory, Fourth Edition22 Creating Hierarchy Charts Hierarchy chart: –Illustrates modules’ relationships –Tells which routines call which other routines –Does not tell when or why the modules are called

23 Programming Logic and Design, Introductory, Fourth Edition23 Creating Hierarchy Charts (continued) Blackened corner indicates a module that is used more than once

24 Programming Logic and Design, Introductory, Fourth Edition24 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

25 Programming Logic and Design, Introductory, Fourth Edition25 Output Documentation Usually written first Represents the information needed by end users May be initially created by end users Printed reports: designed using a print chart

26 Programming Logic and Design, Introductory, Fourth Edition26 Output Documentation (continued) Printed reports usually contain: –Detail lines: display data details –Heading lines: contain title and column headings –Total (or summary) lines: may contain statistics or end of report indicators Printed reports may contain only summary information Reports may be displayed on screens and not printed GUI: graphical user interface

27 Programming Logic and Design, Introductory, Fourth Edition27 Input Documentation Input documentation: describes what input is available to produce the output File description: –Describes the data stored in a file –Indicates fields, data types, and lengths

28 Programming Logic and Design, Introductory, Fourth Edition28 Input Documentation (continued) Byte: unit of computer storage that can contain any of 256 combinations of 0s and 1s to represent characters Programmers usually create one variable for each data field in an input file Some report fields may be calculated results

29 Programming Logic and Design, Introductory, Fourth Edition29 Input Documentation (continued) Programmers need to know: –Data file name –Data fields and their order within the file –Data types of each field

30 Programming Logic and Design, Introductory, Fourth Edition30 Input Documentation (continued)

31 Programming Logic and Design, Introductory, Fourth Edition31 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

32 Programming Logic and Design, Introductory, Fourth Edition32 Completing the Documentation (continued) User documentation: –Written clearly in plain language –Usually prepared by system analysts and/or tech writers User documentation usually indicates: –How to prepare input –Output distribution –Output interpretation –Error message information –Run frequency

33 Programming Logic and Design, Introductory, Fourth Edition33 Summary Modules, subroutines, procedures, functions, methods: smaller, reasonable units of code that provide reusability Modules can call other modules Variable declarations define the name and type of the data to be stored Hierarchy chart illustrates modules’ relationships Documentation: all supporting material for a program

34 Programming Logic and Design, Introductory, Fourth Edition34 Summary (continued) Output documentation: includes report designs File description: details data types and lengths of each field of data in the file User documentation: includes manuals and instructional materials for non-technical people, and operating instructions for operators and data- entry people


Download ppt "Programming Logic and Design Fourth Edition, Introductory Chapter 3 Modules, Hierarchy Charts, and Documentation."

Similar presentations


Ads by Google