# The art of drawing a road map

## Presentation on theme: "The art of drawing a road map"— Presentation transcript:

The art of drawing a road map
Flowchart The art of drawing a road map

Perform Tax Calculation
Symbols Oval (“racetrack”) Start or Stop (Terminator) Rectangle Process (calculation, value assignment, etc) Rectangle with double vertical sides A predefined process Allows you to represent something complicated at an early stage and basically show that “it goes here” in your flow of activity Rhomboid (slanted rectangle) Input / output (data) Diamond Decision Arrows indicate direction or “flow” of activity Small circle (possibly with letter inside) “on page” continuation Home Plate “off page” continuation Start Calculate Avg Perform Tax Calculation Get TempCent Age>21? A AvgGrades

Flowchart Demonstrates a sequence of activities and decisions
Can be used as a roadmap in writing code Certain shapes identify code “structures” Decision structures A condition which evaluates to True or False Asks a question which “directs” the continued flow of activity Repetition structures (loops) A return to a prior point in the flowchart NOTE: this return is based on a condition being either true or false While the shape asking the question is a diamond and could be an “IF” statement, the fact that one of the branches from the diamond returns to a prior point indicates that the conditional question asked is part of a LOOP and not an IF

Flowchart Forces us to think about what we do
We need to identify each discrete action (process) or question (decision) in order to solve the problem Flowcharts can identify that we “missed” something We have a process which calculates “GROSSPAY”, and know that GROSSPAY requires “Hoursworked” and “HourlyPay” as input, but we notice that prior to the calculation, we never bothered to get HoursWorked (missing input) We’ve calculated a result “NETPAY”, however never display it to the user (output of our solution) Flowcharts can identify a sequencing error We display a result prior to calculating it We can think about things more abstractly Calculate Grosspay If we know someone worked 10 hours at \$15/hour the calculation is 10 x 15 NOT abstract enough… it only works for that single case Work backwards. What does the 10 represent? [ Hoursworked] Use THAT name to represent any value given

The user gets 3 attempts to provide the valid password If valid Go to the process transaction “off- page” routine If it’s the 3rd failed attempt Stop! Decision “Valid” diamond Repetition 3rd attempt question is part of the LOOP, and not simply an IF How you can identify the difference between which structure to code (IF vs. LOOP)

IF statement / variations
blnPass=False If AvgGrade > 65 then blnPass=TRUE IF ..ELSE..ENDIF If AvgGrade > 65 then blnPass=True Else blnPass = False End If IF .. ELSEIF… ENDIF If Avg >=90 then LG = “A” ElseIf Avg >= 80 LG = “B” ElseIf Avg >= 70 LG = “C” Else LG = “F” End If

Filling in symbols Processes Decisions Use a “verb” or action word
Think of each process as its own little “IPO” (Input-Process-Output) Do you have all of the required inputs to do the process at that point in time? If not, maybe you missed a step somewhere Decisions True or false Comparison Age>21 Counter <= 3 State Grade exists?

Slow down! Draw a flowchart finding the average of 3 grades
How would you do it with paper and pencil? Take the first grade Add the 2nd to the first grade Add the 3rd to that You’re “accumulating” (totaling) the grades In English… “I’m adding to the grade total” After grade total is calculated Calculate the final average by dividing it by the number of grades (3) Show the answer

Average of “n” grades You’ll still do the same process