Chapter 2 Problem Solving Abstraction and Stepwise Refinement
Chapter 2 Problem Solving, Abstraction, and Stepwise Refinement
Chapter 2 • The Programmer’s Algorithm Define the problem. Plan the problem solution. Code the program. Test and debug the program. Document the program.
Chapter 2 • Define the Problem The problem must defined in terms of output, input, and processing. Look for nouns in the problem statement that suggest output and input. Look for verbs to suggest processing steps.
Chapter 2 • Plan the Solution When planning computer programs, algorithms are used to outline the solution steps using Englishlike statements, called pseudocode. A good pseudocode algorithm should be independent of, but easily translated into, any formal procedural programming language.
Chapter 2 • Code the Program Coding involves the actual writing of the program in a formal programming language. Once a language is chosen, the program is written, or coded, by translating your algorithm steps into the formal language code.
Chapter 2 • Debug the Program Realize that you have an error. Locate and determine the cause of the error. Fix the error. – Desk-check the program, – Compile the program. – Run the program. – Debug the program using a debugger.
Chapter 2 • Document the Program The final program documentation is simply the recorded result of the problem definition, solution planning, coding, testing results, debugging results, and user instructions.
Chapter 2 • Problem Abstraction provides for generalization in problem solving by allowing you to view a problem in general terms, without worrying about the details of the problem solution.
Chapter 2 • Stepwise Refinement Stepwise refinement is the process of gradually adding detail to a general problem solution until it can be easily coded in a computer language.
- Slides: 9