Upload
dee-can
View
216
Download
0
Embed Size (px)
Citation preview
8/6/2019 Cse120wi11lec22[1] Debugging
1/16
Debugging warm-up activity find a partner find the bugs (errors) in the Scratchcode it is okay if you dont come up with the
Scratch solution but you should talk
with you partner about the bug and howeach of you might fix it
hint: there is no one right answer!Friday,February24,2011 SlidesbySusanEvans 1
8/6/2019 Cse120wi11lec22[1] Debugging
2/16
Possible Scratch Solutions
Friday,February24,2011 SlidesbySusanEvans 2
8/6/2019 Cse120wi11lec22[1] Debugging
3/16
What process did you follow
when looking for bugs?
Friday,February24,2011 SlidesbySusanEvans 3
8/6/2019 Cse120wi11lec22[1] Debugging
4/16
?
term coined by Grace Hopper in the1940s when she found a moth in theMark II computer she was working on
the moth was jammed in one of therelays causing the computer to fail
debugging: method of figuring out why aprocess or system doesnt work properly.
Friday,February24,2011 SlidesbySusanEvans 4
8/6/2019 Cse120wi11lec22[1] Debugging
5/16
Debugging
will be talking about 2 overall themesthroughout the lecture
debugging software/hardware you usein everyday life but do not write or build
debugging code that you write (e.g.,Processing code)
Friday,February24,2011 SlidesbySusanEvans 5
8/6/2019 Cse120wi11lec22[1] Debugging
6/16
Who is to blame for bugs in
software? You! .. usually computers are predictable they do exactly what they are told to do computers cant think for themselves if they werent programmed to do it; they
will fail software errors are much more rare than
human errors!
Friday,February24,2011 SlidesbySusanEvans 6
8/6/2019 Cse120wi11lec22[1] Debugging
7/16
Consider 0s (zeros) and Os (ohs)
or even ls (els) and 1s (ones) for thatmatter
what if the user types in an oh whenthey mean a zero
how could the computer be programmedto figure it out?
Friday,February24,2011 SlidesbySusanEvans 7
8/6/2019 Cse120wi11lec22[1] Debugging
8/16
Consider 0s (zeros) and Os
(ohs) could be programmed to converted ohs to
zeros
but what if each has a different meaning can you think of any situations where it
would be important to know which one theuser entered?
now it becomes very important for the userto be very precise when enteringinformation
Friday,February24,2011 SlidesbySusanEvans 8
8/6/2019 Cse120wi11lec22[1] Debugging
9/16
Debugging in Everyday Life
you more than likely have debugged longbefore the start of learning Processing inthis class
can you think of anything you havedebugged?
Friday,February24,2011 SlidesbySusanEvans 9
8/6/2019 Cse120wi11lec22[1] Debugging
10/16
Debugging Process
1. run the program; reproduce the sameexact error
2. state/determine the error 3. eliminate the obvious cases 4. Divide! Eliminate the parts of code that
work properly
5. Go back to step 1
Friday,February24,2011 SlidesbySusanEvans 10
8/6/2019 Cse120wi11lec22[1] Debugging
11/16
Debugging Process
1. run the program; reproduce the sameexact error
why?
Friday,February24,2011 SlidesbySusanEvans 11
8/6/2019 Cse120wi11lec22[1] Debugging
12/16
Debugging Process
2. state/determine the error 3. eliminate the obvious cases how do we do this in Processing? in
Scratch?
Friday,February24,2011 SlidesbySusanEvans 12
8/6/2019 Cse120wi11lec22[1] Debugging
13/16
Debugging Process
4. Divide! Eliminate the parts of codethat work properly
why would this make it easier? lets take a look at Chelsey and Lisas
code
they have a bug, but there code is 7pages long! we need to narrow down theproblem.
Friday,February24,2011 SlidesbySusanEvans 13
8/6/2019 Cse120wi11lec22[1] Debugging
14/16
Debugging Process
in groups of 3 or 4 find the bug in theircode
fix it on paper Chelsey & Lisa prepare a brief
explanation to give to the class about
the bug once they have found it
Friday,February24,2011 SlidesbySusanEvans 14
8/6/2019 Cse120wi11lec22[1] Debugging
15/16
Debugging Process
5. Go back to step 1 why? When should you stop the process?
Friday,February24,2011 SlidesbySusanEvans 15
8/6/2019 Cse120wi11lec22[1] Debugging
16/16
User Friendly Programing
how can you write user friendly code sothat the user knows when they haveentered bad information?
lets take a look at Shari and Stefanscode
Friday,February24,2011 SlidesbySusanEvans 16