the information school of the university of washington oct 9fit100-06-debug1 debugging and...
TRANSCRIPT
Oct 9 fit100-06-debug 1
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Debugging and Troubleshooting
INFO/CSE 100, Fall 2006
Fluency in Information Technology
http://courses.washington.edu/info100/
Oct 9 fit100-06-debug 2
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Readings and References
• Reading» Fluency with Information Technology
• Chapter 7, To Err is Human“To err is human, but it takes a computer to really
foul things up”
• References» World Wide Web Consortium
• http://www.w3schools.com/html/html_reference.asp
• http://validator.w3.org
» Jedit (java-based editor)• http://www.jedit.org
Oct 9 fit100-06-debug 3
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Anchors
• The link starts with an a tag…<a href=" ... ">
• The value of the href attribute is a URL. <a href="http://www.cs.washington.edu">
• The link encloses some text, and ends with… <a href=" ... ">CSE home page</a>
Oct 9 fit100-06-debug 4
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Types of URLS
• http://www.site.com/dir/file.html
• http://www.site.com/dir/
• ftp://ftp.site.come/pub/
• news:soc.culture.religion
• mailto:[email protected]
• file:///hardisk/path/file.html
Oct 9 fit100-06-debug 5
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
HTML Tables<table border="1"> <tr> <th>Animal</th> <th>Fav food</th>
</tr> <tr> <td>monkeys</td> <td>bananas</td> </tr> <tr><td colspan="2"><hr /></td></tr></table>
Animal Fav food
monkeys bananas
___________________
Oct 9 fit100-06-debug 6
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Simple HTML
• What we’ve seen here is very simple HTML
• HTML is changing» Each document should start with a “DOCTYPE” comment telling which
version of HTML it follows• http://www.w3.org/QA/2002/04/valid-dtd-list.html
• We used HTML 4.01 Transitional
» There is a validator service that will check your page• http://validator.w3.org/
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Oct 9 fit100-06-debug 7
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Editing byHand vs. a Tool
• WYSIWYG type tools (what you see is what you get)» Microsoft FrontPage - $$$» Macromedia DreamWeaver - $$$» Amaya - Free
• http://www.w3.org/Amaya/
» And MANY MANY others!
• Text Editors» Jedit - Free
• http://www.jedit.org/
• Pick the right tool for you!
Oct 9 fit100-06-debug 8
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Character Entities
• Some characters are special in HTML» <, >, &, ", '
• They are interpreted by the web browser• To get them to display properly we have to encode
them specially» < = <» > = >» & = &» " = "» ' = '» = non-breaking space
Oct 9 fit100-06-debug 9
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Using Computers...
• In IT, stuff goes wrong … debugging is the process of finding the error» Term coined by Grace Murray Hopper
• Best solution … make no mistakes!» Be accurate … get it right the 1st time» Follow a process that makes it easier to get it
right» Computers can’t make "common sense"
decisions about what we really meant. They do what we say, not what we mean.
Oct 9 fit100-06-debug 10
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Cost of Debugging
• Debugging may consume 60-70% of your development time
• 80% of overruns may be due to debugging» Keep this in mind when you are budgeting time
for your projects!
Oct 9 fit100-06-debug 11
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Common Bug Types
• Compilation/Syntax errors» Program won’t run due to problems with what
you typed in• HTML tags must be entered precisely
• Required attributes must be present
• Logic errors» Program runs, but output/behavior is wrong
Oct 9 fit100-06-debug 12
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
When You Debug...
• There are guidelines for debugging…Rather than trying things aimlessly and becoming frustrated, think of yourself as solving a mystery• Be objective: What are my clues? What is my hypothesis?
Do I need more data?
• Consciously ‘watch’ yourself debug -- its an out-of-body experience
• When stumped, don’t become frustrated, but ask, “What am I misunderstanding?”
Become Sherlock Holmes
Debugging is not algorithmic: no guaranteed process
Oct 9 fit100-06-debug 13
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Debugging Guidelines Overview
» Verify that the error is reproducible» Determine exactly what the actual failure is» Eliminate the “obvious” causes by checking» Divide process into working/faulty parts» On reaching a dead end, reassess the information
you have, trying to identify the mistake you are making
» Work through process making predictions and checking they’re fulfilled
Oct 9 fit100-06-debug 14
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
• First step: verify the error is reproducible» You can't find something that you can't reproduce» Get out and get back in. Does it still happen?
• Restart the application.
• Try a different application
• Reboot the operating system. Sometimes this is appropriate, especially for errors involving peripheral devices (printers, modems)
Getting Out and Getting Back In
Reproducibility
Oct 9 fit100-06-debug 15
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
tonDetermine the Problem
• Second step: figure out what’s wrong» Often there is a sequence of steps following an
error and propagating it … work backwards looking to see where the error first occurred
Empty Database
Mailing Label Pgm
Mailing Label File
No Labels Printing
This is not a printer problem!
Oct 9 fit100-06-debug 16
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
tonEliminate the Obvious
• Third step: eliminate obvious causes“If the cause were obvious, the problem would have been fixed!” - Yeah, right.
» There are standard things to check: • Inputs• Connections• “Permissions”• Physical connectivity• Requirements
My fan is broken, it won't
turn on!
Oct 9 fit100-06-debug 17
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Isolate the Problem
• Try to “partition” the situation into working and non-working parts
• Form a hypothesis of what’s wrong
• Make as few assumptions as possible
• Take nothing for granted
The goal is to eliminate as many things from consideration as possible
Oct 9 fit100-06-debug 18
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
tonAt a Dead End, Reassess
• When everything seems to check out, don’t get frustrated
• Instead, ask yourself “What am I overlooking or misunderstanding?”» Your goal is to see the situation as it is, not as you
think it should be• Am I assuming too much?• Am I misreading the clues?• What can I eliminate or simplify?
• Explain the situation to a friend
Oct 9 fit100-06-debug 19
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
tonMake Predication/Check
• Beginning with the isolated part, step through the process, predicting the outcome and verifying it» A prediction that is not fulfilled shows…
• A possible bug
• A possible misunderstanding
• A chance to narrow the search
‘Sleeping on it’ often helps!
Oct 9 fit100-06-debug 20
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Questions
• Why learn HTML at all if authoring tools will do the work for you?
• Give other examples of where you are expected to learn something when there are tools available that will do the work.
Oct 9 fit100-06-debug 21
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Questions
• Why do we need to end a tag?
• Why were the characters < and > chosen to denote tags?
Oct 9 fit100-06-debug 22
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Questions
• How does a web browser know where to get an image from to display on a web page?
Oct 9 fit100-06-debug 23
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Questions
• You walk into a room and flip the light switch. Nothing happens. Describe the debugging process you use to solve the problem.
Oct 9 fit100-06-debug 24
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Questions
• What advantages does an organized debugging approach have over a trial and error approach?
Oct 9 fit100-06-debug 25
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Project 1• Make a website of “misinformation”
» Project 1a• Planning, image collection, basic web site creation
» Project 1b• Website design, image manipulation
• Project 1a due Friday, October 13, before 10:00 pm.» Use online turn in page to submit your files» We will not accept late projects - turn in what you have
even if you are not done (some points are better than no points)
• http://courses.washington.edu/info100/classwork/assignments/files/project1.html
Oct 9 fit100-06-debug 26
Th
e I
nfo
rmati
on
Sch
ool
of
the U
niv
ers
ity o
f W
ash
ing
ton
Summary• Debugging is not algorithmic, but there are
guidelines to follow» Stay calm - high blood pressure clouds your brain
» Be organized as you investigate and fix things
» Recognize that you may feel a little embarrassed when you finally figure out the problem. • If we were perfect, we would never make mistakes ...
• A little humility is a good thing for all of us
» Watch yourself debug -- assess how you are doing, what you need to know
» Only try to fix one bug at a time!