developing a solution getting past the panic of staring at a “blank sheet” of paper when solving...
TRANSCRIPT
Developing a Solution
Getting past the panic of staring at a “blank sheet” of paper when
solving a problem
1
General Idea of This Lesson
Give you methodology
Example problems: “Find the optimum nozzle dimensions for …” “Solve for the optimum path for the robot …” “Find the range of temperatures adequate for …”
In EGR115, most tasks will be:
“Develop a software that solves……”
General Terms
As a programmer, keep in mind there are 2 sides to a software The person who writes the software: the programmer The person who uses the software: the user , or client !
As you (student) develop a software, constantly jump back and forth between the two roles.
“The programmer should make the user’s life easy.”
3
The 5 step process
Follow these steps in order:
1. State the problem clearly
2. Identify the givens vs. the results wanted This will be referred as the I/O diagram
3. Manually solve the problem
4. Computerize the solution
5. Test, test, test!!!
4
Step 1. State the problem
However the problem may seem, it is crucial to fully understand the problem, and clarify any doubts.
For example: Generate a software that “Solves the area of any triangle” What way would you go about doing this:
On Paper first
5
Step 2. Identify the I/O
What do you know about the problem? How do you want to solve it?
6
height
base
Step 2. Identify the I/O
What do you know about the problem? How do you want to solve it?
7
side 1
side 2
angleheight
base
Step 2. Identify the I/O
Remember the Von Neumann architecture? CPU + memory + inputs/outputs devices
The I/O diagram determines which input and output devices the software uses, as well as decide which inputs and output variables are used.
The I/O diagram is a first step to organizing the brainstorming.
8
General frame of an I/O diagram
Arrows indicate and names each given and result Purple boxes indicate which devices are used
9
?
?
?
??
?
?
?
General frame of an I/O diagram
10
INPUT SIDE
?
?
?
??
?
?
?
General frame of an I/O diagram
11
OUTPUT SIDE
?
?
?
??
?
?
?
Applied to the area of triangle
12
AREA OF TRIANGLE
Applied to the area of triangle
13
AREA OF TRIANGLE
Sides 1 and 2
Angle
Each arrow represents the INPUTS
(=GIVENS)
Applied to the area of triangle
14
AREA OF TRIANGLE
Sides 1 and 2
Angle
External interface – What DEVICE is used to enter the values of the givens
Keyboard
Each arrow represents the INPUTS
(=GIVENS)
Applied to the area of triangle
15
AREA OF TRIANGLE
Sides 1 and 2
Angle
Keyboard
Each arrow represents the INPUTS
(=GIVENS)
area
Each arrow represents the OUTPUTS
(=RESULTS)
Applied to the area of triangle
16
AREA OF TRIANGLE
Sides 1 and 2
Angle
External interface – What DEVICE is used to see the results
Keyboard
Each arrow represents the INPUTS
(=GIVENS)
Screenarea
Each arrow represents the OUTPUTS
(=RESULTS)
Applied to the area of triangle
Final I/O diagram
17
AREA OF TRIANGLE
Sides 1 and 2
Angle
Keyboard Screenarea
Same problem: Option 2
18
AREA OF TRIANGLE
Sides 1 and 2
Angle
Printer
Different input/output devices
area
18
Microphone
… or option 3 …
19
AREA OF TRIANGLEbase
height
Screenarea
19
Keyboard
Different Inputs
Some Other More Complex Examples (and yet, the I/O is not so complex)
2020
ATM MACHINE
Some Other More Complex Examples (and yet, the I/O is not so complex)
2121
ATM MACHINE
Account numberCard
Some Other More Complex Examples (and yet, the I/O is not so complex)
2222
ATM MACHINEpin
Deposit/with-draw/transfer…
Touch Screen/ pin pad
Account numberCard
Some Other More Complex Examples (and yet, the I/O is not so complex)
2323
ATM MACHINEpin
Deposit/with-draw/transfer…
Touch Screen/ pin pad
Account numberCard
Money Slot
money
Some Other More Complex Examples (and yet, the I/O is not so complex)
2424
ATM MACHINEmoney Money Slotpin
Deposit/with-draw/transfer…
Touch Screen/ pin pad
Account numberCard
Money Slot
money
Some Other More Complex Examples (and yet, the I/O is not so complex)
2525
ATM MACHINEmoney Money Slotpin
Deposit/with-draw/transfer…
Touch Screen/ pin pad
Account numberCard
receiptReceipt Slot
Money Slot
money
Step3. Manually Solve Problem
Solving the area of a triangle is obvious
Height = 3 in Base = 2 in
Area = ½ * 2 * 3
= 3 in squared
26
Step 4 and Step 5
These steps actually involve owning a computer and starting to type ‘lines of code’.
Realize that none of the steps before did.
In short: Step 4 – Computerize the solution Step 5 – Test the software created
Remember: “SIMCT”(or: Small iPods Make Copying Tough)
1. S State the problem (clarify it if need be)
2. I Identify the Inputs and Outputs
3. M Manually solve the problem
4. C Computerize the solution1. Layout the algorithm
2. Provide the code that implements the algorithm
5. T test, Test, TEST!!
28
1. S State the problem (clarify it if need be)
2. I Identify the Inputs and Outputs
3. M Manually solve the problem
4. C Computerize the solution1. Layout the algorithm
2. Provide the code that implements the algorithm
5. T Test, Test, TEST!!
Remember: “SIMCT”(or: Small iPods Make Copying Tough)
29
Note: I and M are usually mixed up. You obvioulsy need to brainstorm, solve the problem, find obstacles to fix, resolve it again to eventually zoom in on the correct inputs/outputs.. Spend the most time here before coding.