Page last updated 08/23/99
Exercises, Analysis and Design Projects
| Step | Process | Deliverables |
|---|---|---|
| Analysis | Understand the problem | A document that lists the useful data objects |
| Design | Organize the solution | An algorithm that outlines a solution |
| Implementation | Get the solution running | An executable program |
Synonyms of analysis
Activities of analysis
- these names of data are part of the solution ("variables").
Compute the maximum airplane takeoff weight.
The data things are called objects and have these three important characteristics:
Find the length of a line segment.
The line is represented by Cartesian coordinates of its end points, e.g. (1,1) to (5,4)
The formula for the length of a line segment is
= 5
What are input variables and output variables? ____________________________________
Consider the following problems. What variables would be necessary in the solution? Choose useful names and give a sample value for each. Would that variable be used as input or output?
| Problem Description | Object Name / Sample Data | Input or Output? |
|---|---|---|
| Compute the average of three test scores |
||
| Compute the roots of a quadratic equation: ax2 + bx
+ c |
||
| Compute a loan payment |
Activities performed during analysis
Using the grade assessment scale (weighted average) below, compute the weighted average for any combination of two tests and a final.
| Objects | Sample Problem 1 | Sample Problem 2 | Input or Output |
|
|
|||
|
|
|||
|
|
|||
|
|
Synonyms of design: model, think, plan, devise, pattern, propose, outline
We'll use these design tools:
An algorithm is a set of activities that solves a problem.
An algorithm must:
Bake a Cake
Pattern: Input/Process/Output (IPO)
Problem situation: The program requires input to generate the desired info.
Outline of IPO:
"Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice."
From A Pattern Language, Christopher Alexander, Oxford University Press
The deliverable from this design phase will be an algorithm.
The IPO patterns provides a guide to design this more specific algorithm (that is a bit sketchy:
IPO Model One Specific IPO Case Study
I)nput Obtain test1, test2, and finalExam
P)rocess Compute the course grade
O)utput Display the course grade
Usually a number of steps must be refined into substeps.
For example, Compute the course grade might now be refined with the C++ mathematical addition + and multiplication * symbols and names for the objects:
courseGrade = test1 * 0.25 + test2 * 0.25 + finalExam * 0.50 ;
Suggestion: Use an algorithm walkthrough to review the algorithm
Simulate what the computer would do if given the instructions.
An example walkthrough
Input) Retrieve some example values from the user and store them into the objects as shown:
Processing) Retrieve input data and compute courseGrade as follows
courseGrade=(0.25*test1)+(0.25*test2)+(0.50*finalExam)
(0.25*80.0) + (0.25*90.0)+(0.50*100.0)
(20.0 + 22.5 + 50.0)
courseGrade = 92.5
Output) Show course grade to the user:
Note: Retrieve the data stored in courseGrade to show: 92.5%