program design. the design process how do you go about writing a program? –it’s like many other...

5
Program Design

Upload: jonas-robbins

Post on 17-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop

Program Design

Page 2: Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop

The design process

• How do you go about writing a program?– It’s like many other things in life

• Understand the problem to be solved• Develop a plan of attack (we call this the

algorithm)• Execute your plan of attack (write the program)

Problem Algorithm Implementation

Problem solving phase Implementation phase

Page 3: Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop

Algorithm

• A sequence of precise instructions which leads to a solution is called an algorithm.– Ex: compute the product of two integers

– Input two numbers, e.g., N1 and N2– Product, P, initially set to 0– Add the first number, i.e. N1, to P– Decrement N2– Check whether N2 is 0 or not– If N2 is 0, output P and stop– If not, repeat these steps starting at the addition above

Page 4: Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop

Algorithms• The biggest error you can make in

computer programming– Skipping the “Develop the Algorithm” phase– Sometimes hard to see with the simple

programs in this course, but with more difficult programs jumping right to the implementation is unwise

Problem ImplementationAlgorithm

Page 5: Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop

Program Design