Chapter 3: Modularization

Slides:



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

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.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Chapter 2 - Problem Solving
Programming Logic and Design Fourth Edition, Introductory
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Program Design and Development
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Chapter 2: Input, Processing, and Output
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Modules, Hierarchy Charts, and Documentation
Understanding the Mainline Logical Flow Through a Program (continued)
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
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.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Programming Logic and Design Fourth Edition, Introductory
An Overview of Computers and Programming
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CS102 Introduction to Computer Programming
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Programming Logic and Design Fifth Edition, Comprehensive
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
Structured COBOL Programming, Stern & Stern, 9th edition
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
Simple Program Design Third Edition A Step-by-Step Approach
Planning for the Solution
Programming Logic and Design Fifth Edition, Comprehensive
Lesson 3 McManus COP  You have to tell them ◦ what to do ◦ what to use ◦ in what order to do itand ◦ what to do if your user does not do what.
Computer Concepts 2014 Chapter 12 Computer Programming.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
SE: CHAPTER 7 Writing The Program
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Programming Logic and Design Seventh Edition
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
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.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
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 FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
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.
Chapter 1 Introduction(1.1)
Programming Logic and Design Fourth Edition, Comprehensive
Writing a Complete Program
Topics Introduction to Functions Defining and Calling a Function
Modules, Subroutines, Procedures, Functions, or Methods
Chapter 4: Writing and Designing a Complete Program
Programming Logic and Design Eighth Edition
Presentation transcript:

Chapter 3: Modularization

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

Documentation Documentation 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 Internal program documentation: comments within code External program documentation: supporting paperwork written before programming begins

Output Documentation Figure 3-2 Inventory records displayed in a GUI environment Figure 3-3 Inventory records displayed in a running program

Figure 3-6 Inventory file description 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 Figure 3-6 Inventory file description

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

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

Modularization Module: Invoke (call) a method is to execute it Unit of code that performs one small task Called a subroutine, procedure, function, or method Invoke (call) a method is to execute it Calling method invokes the called method Program contains unlimited number of methods Each method can be called unlimited number of times

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

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

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

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

Modularizing a Program Most programs contain a main program Contains the mainline logic Accesses other modules or subroutines Rules for naming modules different for every programming language For this text: Must be one word Should be meaningful Followed by a set of parentheses Corresponds to module naming in Java, C++, C#

Modularizing a Program (continued) Table 3-1 Suggested identifiers for a module that calculates an employee’s gross pay

Modularizing a Program (continued) Calling program (or calling module): one that uses another module Flowchart symbol for calling a module: rectangle with bar across the top Flowchart for the module Start symbol: contains module name Stop symbol: contains exit or return When a module is called, logic transfers to the model When module ends, logic transfers back to the caller

Figure 3-9 Logic from Figure 3-8 using a method Figure 3-8 Sample logic Figure 3-9 Logic from Figure 3-8 using a method

Figure 3-10 Logic from Figure 3-9 using two methods

Modularizing a Program (continued) Method is encapsulated in another method if it is contained in another method 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