Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2: Modularization

Similar presentations

Presentation on theme: "Chapter 2: Modularization"— Presentation transcript:

1 Chapter 2: Modularization

2 Objectives Understanding Documentation Learn about documentation
Learn about the advantages of modularization Learn how to modularize a program Declare local and global variables and constants Create hierarchy charts

3 Documentation Documentation
Documentation refers all supporting material that goes with a program Two major categories: for users and for programmers User Documentation: End users (people who use computer programs) Program Documentation falls into two categories: Internal program documentation include comments within code External program documentation include supporting paperwork written before programming begins

4 Output Documentation Output documentation is usually the first to be written. user who requested output generally present to programmer with an example. Figure 3-2 Inventory records displayed in a GUI environment Figure Inventory records displayed in a running program

5 Printer Spacing Chart Chapter 3

6 Printer Spacing Chart with Title and Column Headings

7 Input Documentation Describes what input is available to produce the output File description: Describes data stored in a file Indicates fields, data types, and lengths

8 Completing Documentation
Program documentation may contain: Output design Input description Flowcharts Pseudocode Program code listing User documentation may contain: Manuals Instructional material Operating instructions

9 Modularization Modularization: breaking a large program into modules
Advantages of modularization: Provides abstraction Allows multiple programmers to work simultaneously Allows code reuse Makes identifying structures easier

10 Modularizing a Program- Flowchart Symbols
Chapter 3 Sentinel Symbols A module has it own sentinel symbols (Start and End) The Start symbol has the name of the module The End symbol has the word “RETURN”

11 Modularized Logic from a Payroll Program
Chapter 3

12 Modularization Provides Abstraction
Focuses on important properties while ignoring non- essential details Avoids low-level details Makes complex tasks look simple High-level programming languages allow English-like vocabulary One statement corresponds to dozens of machine instructions Modules provide another way to achieve abstraction

13 Modularization Provides Abstraction (continued)
To-do list without abstraction Pick up laundry basket Put laundry basket in car Drive to laundromat Get out of car with basket Walk into laundromat Set basket down . . . To-do list with abstraction Do laundry Call Aunt Nan Start term paper

14 Modularization Allows Multiple Programmers to Work on a Problem
Commercial programs rarely written by a single programmer Development time is significantly reduced Large programming projects can be divided into modules Modules can be written by different programmers or programming teams

15 Modularization Allows You to Reuse Your Work
Subroutines that are useful should be used more than once in a program Example: routine that checks the current date Instructions placed in their own module are easy to port to other applications Reusability: the ability to use modules in a variety of applications Reliability: assurance that a module has been tested and proven to function correctly Reliable software saves times and money

16 Understanding the Mainline Logic for Many Procedural Programs
Mainline logic of most procedural programs follows same general structure: Housekeeping tasks Variable and constant declarations Opening files Main loop tasks Processes that must occur for every data record End-of-job tasks Print footer lines Close open files

17 Understanding the Mainline Logic for Many Procedural Programs (continued)
Figure Flowchart and pseudocode of mainline logic for a typical procedural program

18 An Organizational Hierarchy Chart

19 Local and global variable
Local These variables only exist inside the specific function that creates them. They are unknown to other functions and to the main program. scope is limited to that function. Global These variables can be accessed (ie known) by any function comprising the program

20 Example of local variable
main() { int i=4; i++; }

21 Example of global variable
int i=4; main() { i++; }

22 int i=4; /. Global definition. / main() { i++; /. global variable
int i=4; /* Global definition */ main() { i++; /* global variable */ func } func() { int i=10; /* Internal declaration */ i++; /* Internal variable */

Download ppt "Chapter 2: Modularization"

Similar presentations

Ads by Google