Motivation Complexity of programming problem  more difficult to consider the solution as a whole  clue: dividing the problem into small parts (module)

Slides:



Advertisements
Similar presentations
Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
Advertisements

Programming Logic and Design Fourth Edition, Introductory
Selection control structures
Assistanship Assistant: Denny, TE 2002 Type: not compulsary, only when necessary Duration: once a week, not more than 2 hours. Time,place: ask assistant.
Program Design and Development
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Modularisation II Lecture 9. Communication between modules Also known as intermodule communication. The fewer and the simpler the communications, the.
Chapter 1 Principles of Programming and Software Engineering.
Understanding the Mainline Logical Flow Through a Program (continued)
Pseudocode.
Chapter 1 Program Design
Pseudocode Algorithms Using Sequence, Selection, and Repetition.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Pseudocode.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
DCT 1123 Problem Solving & Algorithms
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Combination of Sequence, Selection and Repetition
Pseudocode algorithms using sequence, selection and repetition
DCT 1123 Problem Solving & Algorithms
Simple Program Design Third Edition A Step-by-Step Approach
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
First Steps in Modularization Simple Program Design Third Edition A Step-by-Step Approach 8.
Developing an Algorithm
Selection Control Structures Simple Program Design Third Edition A Step-by-Step Approach 4.
Chapter 7 Array processing. Objectives To introduce arrays and the uses of arrays To develop pseudocode algorithms for common operations on arrays To.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
1 Life Cycle of Software Specification Design –Risk Analysis –Verification Coding Testing –Refining –Production Maintenance.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Cs413_design04.ppt Design and Software Development Design : to create a functional interface that has high usability Development : an organized approach.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
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.
Chapter 8 First steps in modularisation. Objectives To introduce modularisation as a means of dividing a problem into subtasks To present hierarchy charts.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Cosc175/module.ppt1 Introduction to Modularity Function/procedures void/value-returning Arguments/parameters Formal arguments/actual arguments Pass by.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language 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.
Flowcharts. Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in.
Flowcharts Lecture 12.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Array Applications. Objectives Design an algorithm to load values into a table. Design an algorithm that searches a table using a sequential search. Design.
 Problem Analysis  Coding  Debugging  Testing.
Further Modularization, Cohesion, and Coupling. Simple Program Design, Fourth Edition Chapter 9 2 Objectives In this chapter you will be able to: Further.
Integrating Algorithms and Coding into the Mathematics Classroom
Principles of Programming & Software Engineering
Chapter 2: Input, Processing, and Output
Principles of Programming and Software Engineering
PROGRAM CONTROL STRUCTURE
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.
Figure 1.1 The life cycle of software as a water wheel that can rotate from one phase to any of phase.
Figure 1.1 The life cycle of software as a water wheel that can rotate from one phase to any of phase.
Designing and Debugging Batch and Interactive COBOL Programs
Problem Solving Techniques
Pseudocode algorithms using sequence, selection and repetition
Chapter 6 : Algorithm Development
Chapter 2: Input, Processing, and Output
Chapter 2. Problem Solving and Software Engineering
Top-Down Design & JSP Skill Area Part D
Assistanship Assistant : Denny, TE 2002
Introduction to Pseudocode
Presentation transcript:

Motivation Complexity of programming problem  more difficult to consider the solution as a whole  clue: dividing the problem into small parts (module) Each module represent single task, free of error Modularisation : is the process of dividing a problem into separate tasks, each with a single purpose.

Benefits of modular design Ease of understanding  each module has only one function Reusable code Elimination of redundancy  avoid the repetition of writing Efficiency of maintenance

Modular name convention Describe the work to be done as a single specific function Use a verb, followed by a two-word object. Example: –Print_page_heading –Calculate_sales_tax –Validate_input_date

Example 8.1 Design a solution algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen. The algorithm is to continue to read characters until ´XXX´is entered.

Defining diagram InputProcessingOutput Char_1 Char_2 Char_3 Prompt for characters Accept three characters Sort three characters Ouput three characters Char_1 Char_2 Char_3

Original Solution algorithm Process_three_characters Prompt the operator for char_1, char_2, char_3 Get char_1, char_2, char_3 DOWHILE NOT (char_1=´X`AND char_2=´X´AND char_3=´X´) IF char_1>char_2 THEN temp = char_1 char_1 = char_2 char_2 = temp ENDIF IF char_2>char_3 THEN temp = char_2 char_2 = char_3 char_3 = temp ENDIF IF char_1>char_2 THEN temp = char_1 char_1 = char_2 char_2 = temp ENDIF Output to the screen char_1, char_2, char_3 Prompt operator for char_1, char_2, char_3 Get char_1, char_2, char_3 ENDDO END

Solution Algorithm using a module Process_three_characters Prompt the operator for char_1,char_2,char_3 Get char_1, char_2, char_3 DOWHILE NOT (char_1=´X`AND char_2=´X´AND char_3=´X´) Sort_three_characters Output to the screen char_1,char_2,char_3 Prompt operator for char_1, char_2, char_3 Get char_1,char_2,char_3 ENDDO END Sort_three_characters IF char_1>char_2 THEN temp = char_1 char_1 = char_2 char_2 = temp ENDIF IF char_2>char_3 THEN temp = char_2 char_2 = char_3 char_3 = temp ENDIF IF char_1>char_2 THEN temp = char_1 char_1 = char_2 char_2 = temp ENDIF END ´Controlling module´or ´Calling module´or ´Mainline“ `Subordinate module` or `Called Module`

Hierarchy Chart Example 8.1 Process_three_ characters Sort_three_ characters Calling module Called module

Example 8.2 Process three characters Design a solution algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen. The algorithm is to continue to read characters until ´XXX´is entered.

Defining diagram InputProcessingOutput Char_1 Char_2 Char_3 Prompt for characters Accept three characters Sort three characters Ouput three characters Char_1 Char_2 Char_3

Solution Algorithm Process_three_characters Read_three_characters DOWHILE NOT (char_1=´X`AND char_2=´X´AND char_3=´X´) Sort_three_characters Print_three_characters Read_three_characters ENDDO END Read_three_characters Prompt the operator for char_1,char_2,char_3 Get char_1, char_2, char_3 END Sort_three_characters IF char_1>char_2 THEN temp = char_1 char_1 = char_2 char_2 = temp ENDIF IF char_2>char_3 THEN temp = char_2 char_2 = char_3 char_3 = temp ENDIF IF char_1>char_2 THEN temp = char_1 char_1 = char_2 char_2 = temp ENDIF END Print_three_characters Output to the screen char_1, char_2, char_3 END Mainline 1rst Module 2nd Module 3rd Module

Hierarchy charts Process_three_ characters Read_three_ characters Sort_three_ characters Print_three_ characters