close

Вход

Забыли?

вход по аккаунту

код для вставкиСкачать
The Information School of the University of Washington
Debugging and Troubleshooting
INFO/CSE 100, Fall 2006
Fluency in Information Technology
http://courses.washington.edu/info100/
Oct 9
fit100-06-debug
1
The Information School of the University of Washington
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)
•
Oct 9
http://www.jedit.org
fit100-06-debug
2
The Information School of the University of Washington
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
3
The Information School of the University of Washington
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
4
The Information School of the University of Washington
HTML Tables
<table border="1">
<tr>
<th>Animal</th>
<th>Fav food</th> Animal
Fav food
</tr>
monkeys
bananas
<tr>
<td>monkeys</td> ___________________
<td>bananas</td>
</tr>
<tr><td colspan="2"><hr /></td></tr>
</table>
Oct 9
fit100-06-debug
5
The Information School of the University of Washington
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
» There is a validator service that will check your page
• http://validator.w3.org/
Oct 9
fit100-06-debug
6
The Information School of the University of Washington
Editing by
Hand 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
7
The Information School of the University of Washington
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
»
»
»
»
»
»
Oct 9
&lt; = <
&gt; = >
&amp; = &
&quot; = "
&apos; = '
&nbsp; = non-breaking space
fit100-06-debug
8
The Information School of the University of Washington
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
9
The Information School of the University of Washington
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
10
The Information School of the University of Washington
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
11
The Information School of the University of Washington
When You Debug...
Debugging is not algorithmic: no guaranteed process
• There are guidelines for debugging…
Rather than trying things aimlessly and
becoming frustrated, think of yourself as
solving a mystery
•
•
•
Oct 9
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
fit100-06-debug
12
The Information School of the University of Washington
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
13
The Information School of the University of Washington
Reproducibility
• 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
Oct 9
fit100-06-debug
14
The Information School of the University of Washington
Determine 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
This is not a
printer problem!
Empty
Mailing
Database Label Pgm
Oct 9
Mailing
Label File
No Labels
Printing
fit100-06-debug
15
The Information School of the University of Washington
Eliminate 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:
•
•
•
•
•
Oct 9
Inputs
Connections
“Permissions”
Physical connectivity
Requirements
fit100-06-debug
My fan is
broken, it won't
turn on!
16
The Information School of the University of Washington
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
17
The Information School of the University of Washington
At 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
18
The Information School of the University of Washington
Make 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
19
The Information School of the University of Washington
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
20
The Information School of the University of Washington
Questions
• Why do we need to end a tag?
• Why were the characters < and > chosen to
denote tags?
Oct 9
fit100-06-debug
21
The Information School of the University of Washington
Questions
• How does a web browser know where to get
an image from to display on a web page?
Oct 9
fit100-06-debug
22
The Information School of the University of Washington
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
23
The Information School of the University of Washington
Questions
• What advantages does an organized
debugging approach have over a trial and error
approach?
Oct 9
fit100-06-debug
24
The Information School of the University of Washington
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/a
ssignments/files/project1.html
Oct 9
fit100-06-debug
25
The Information School of the University of Washington
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!
Oct 9
fit100-06-debug
26
1/--страниц
Пожаловаться на содержимое документа