Topic 3 Structured Programming Case Study “ Ugly programs are like ugly suspension bridges: they're much more liable to collapse than pretty ones, because the way humans (especially engineer- humans) perceive beauty is intimately related to our ability to process and understand complexity. ” - Eric Steven Raymond, Author of The Cathedral and the Bazaar and maintainer of The Jargon File CS305j Introduction to Structured Programming Case Study 1 Computing
What We Will Do Today 8 Do a case study 8 case study – an in depth look at a single problem exploring the possible approaches and solutions. CS305j Introduction to Structured Programming Case Study 2 Computing
Desired output /\ / \ / \ \ / \ / \/ \ / \ / \/ /\ / \ / \ /\ / \ / \ +------+ | | | | +------+ |United| |States| +------+ | | | | +------+ /\ / \ / \ CS305j Introduction to Structured Programming Case Study 3 Computing
Various Solutions 8 Unstructured 8 Structured 8 Structured without redundancy – and what is the big deal about redundancy anyway? – what is wrong with copying and pasting? CS305j Introduction to Structured Programming Case Study 4 Computing
It Works 8 If a program works isn’t that all that matters? 8 Aren’t all programs that solve the same problem equivalent? Isn’t one just as good as another? CS305j Introduction to Structured Programming Case Study 5 Computing
Bad Solutions 8 No, all working solutions are NOT equal 8 Some solutions are poor: – hard to change – hard for someone else to understand – brittle, easily broken 8 Problem Statement: Create a device to sharpen pencils CS305j Introduction to Structured Programming Case Study 6 Computing
Open window (A) and fly kite (B). String (C) lifts small door (D) allowing moths (E) to escape and eat red flannel shirt (F). As weight of shirt becomes less, shoe (G) steps on switch (H) which heats electric iron (I) and burns hole in pants (J). Smoke (K) enters hole in tree (L), smoking out opossum (M) which jumps into basket (N), pulling rope (O) and lifting cage (P), allowing woodpecker (Q) to chew wood from pencil (R), exposing lead. Emergency knife (S) is always handy in case opossum or the woodpecker gets sick and can't work. CS305j Introduction to Structured Programming Case Study 7 Computing
Recommend
More recommend