Document 7199502

Download Report

Transcript Document 7199502

Class details
• You folks are great! I have starting reading your
webpages – and will read them all.
• It occurs to me that many of you (a) are hilarious (b) want
to meet people.
• Sharing our webpages will help you to get to know each
other – more than just “nice” – a ticket to success.
• If you don’t want me to put a link to your stuff on my
webpage, send me mail or just remove your page (after it
has been graded).
• Two assignments today – participation1 (blackboard) and
inclass (paper and pencil)
• Written homework due FRIDAY AT CLASSTIME
• Need to log on to Eagle! We are abandoning Blackboard.
1-1
Chapter 4: To Err Is Human:
An Introduction to Debugging
• A big part of working with computers is to reduce errors
and make it easier for human users.
• It is not appropriate to say, “Dumb user. You made a
mistake. You pay the penalty. Bad, bad user.” (This is
Blackboard’s approach to software design.)
• The goal is to make the user’s life easier!
• How is this done?
1-2
I make mistakes
•
•
•
•
•
I say the wrong word.
I type a similar sounding word.
I interchange letters.
I introduce new characters.
The computer needs it to be perfect! Right? What
happened when you didn’t give the correct address for
your webpage?
• The computer needs to bridge the gap between imperfect
humans and its need for perfection.
• We need intelligent systems!
1-3
4-3
Self-correcting codes
• We’ve seen this idea of a computer trying to correct
human error already in Google’s “did you mean?”
• We see forms that complain, “You did not enter a phone
number” and do not let you proceed.
• We see password checkers that say, “Re-enter your
password. The two versions don’t match.”
• Are the steps taken to get correct information ever
obnoxious?
• Can we do less than simply store the information twice?
1-4
4-4
“Magic” Trick- you specify X/blank for each
cell (from CS-unplugged)
x
x
x
x
x
x
x
x
x
x
x
x
1-5
4-5
I add another row and column to
make it more interesting
x
x
x
x x x
x x
x
x
x
x x x
x x
1-6
7-6
Now, you change one cell. Can I tell
which one it was?
x
x
x
x x x
x x
x
x
x
x x x
x
1-7
7-7
Here is the original matrix again
x
x
x
x x x
x x
x
x
x
x x x
x x
1-8
7-8
Try again: I changed a cell. Can you
tell which one it was?
x
x
x
x x
x x
x
x
x
x x x
x x
1-9
7-9
How is it done?
• Called parity: The quality of being either odd or even.
equality; evenness; comparability of strength or intensity
• For even parity, all rows and columns have an even
number of marks.
• Done to insure a bit isn’t lost or data isn’t entered
incorrectly.
• What have you seen done to insure data is correct?
• Why does it work?
• Is it more effective that this technique?
1-10
7-10
Questions- divide room into four
parts (two rows each)
1. It appears you will always detect an error if one cell is
changed. What happens if two or more cells are
changed? Can you detect an error? Can you correct it?
2. What about the lower right hand cell. If you make it
correct for the column above, will it be correct for the row
to the left?
3. What if your table is a rectangle? Will it still work?
4. What if we try odd parity, will it still work? What about the
lower right hand cell?
1-11
4-11
In Class Jan 28th
1. Suppose you are doing even parity. What about the
lower righthand cell. If you make it correct for the column
above, will it be correct for the row to the left?
2. What if we try odd parity, will it still work? What about the
lower right hand cell?
If you say, “Yes, it works” that is hard to prove, as you would
have to show be all possible cases.
If you say, “No, it doesn’t work” You MUST show me the
example that makes it fail. One simple counter-example
is much more convincing that a paragraph of reasoning.
1-12
4-12
In Class Jan 28th
answers:
1. Suppose you are doing even parity. What about the
lower right hand cell. If you make it correct for the
column above, will it be correct for the row to the left?
Yes.
2. What if we try odd parity, will it still work? What about the
lower right hand cell? It doesn’t always work. If you
have an odd number of rows and an even number of
columns (for example), there is a conflict.
x
x
???
1-13
4-13
Class Update
• Homework due WEDNESDAY CLASSTIME.
Will NOT accept late (except for compelling reasons), as we
discuss it in class. Thus, late “due classtime” assignments
are not allowed. Other late assignments are accepted (with
penalty). Read Chapter 4 before completing next homework
– reading through the example makes more sense than
lecturing on it.
• Exam on FRIDAY. I don’t give makeups (except for
COMPELLING reasons). I can’t make up an equivalent test.
Making up a test takes hours and hours. You are expected
to be here.
• Make you get an account on Eagle. Scores are being
transferred.
• Back row – are you with me???
1-14
4-14
Where are the graders?
• Nazneen, you know. The other two are CS grad students.
Wen Ju is a PhD student who moved to California with her
husband. She grades without ever setting foot on campus.
• I would point out the way computers have changed the
way we work. (IPS goal – science affect social)
– Tele-computing
• Parents stay home with children
• Less travel/office expenses
– Out sourcing
– Efficiency – Fast Food orders processed elsewhere. call
center employees from this company process the order instantly and relay it back to
the respective outlets where the orders are displayed on the TV console for the
caterers to attend to the orders and dispatch them and for the cashiers to collect
1-15
the displayed amount. Problem – accent of order takers.
4-15
Change two? Consider removing the
red x’s. Would you notice the error?
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
1-16
7-16
Change two? Changing (x) required
other changes. Took two more
changes in order to get it legal again.
(x)
x
(x)
x
x
x
x
x
x
x
x
+x
x
x
-x
x
x
x
x
x
x
1-17
7-17
Change two? Show me some examples where
changing two things is undetectable.
x
x
x
x
x
x
x
(x)
x
x
x
x
x
x
-x
(x)
x
x
x
-x
1-18
7-18
Corner okay? Seems okay, but always? Why?
Consider adding x’s one at a time.
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
Okay?
x
x
1-19
7-19
Not Square Example
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
1-20
4-20
Odd Parity Example
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
???
1-21
4-21
Simpler odd parity example:
x
x
???
1-22
7-22
Book codes
• This same checking concept is used with book
codes. Published books have a ten-digit code
usually found on the back cover. The tenth digit
is a check digit, in principle like the parity bits in
the exercise.
• This means that if you order a book using its
ISBN (International Standard Book Number), the
publisher can check that you haven’t made a
mistake. They simply look at the checksum. That
way you don’t end up waiting for the wrong book!
1-23
4-23
Here’s how to work out the checksum:
• Multiply the first digit by ten, the second by nine, the third by eight, and
so on, down to the ninth digit multiplied by two. Each of these values is
then added together.
• For example, the ISBN 0-13-911991-4 gives a value
(0 × 10) + (1 × 9) + (3 × 8) + (9 × 7) + (1 × 6)
+ (1 × 5) + (9 × 4) + (9 × 3) + (1 × 2)
= 172
• Then divide your answer by eleven. What is the remainder? 7
Remainders are so important we want to compute them easily. mod
(for modular arithmetic) is the function which computes it. It is called in
Excel as mod(num,11)
• If the remainder is zero, then the checksum is zero, otherwise
subtract the remainder from 11 to get the checksum.
• 11 – 7 = 4
• The result is each multiplied by the integer weight,
descending from 10 to 1, is a multiple of the number 11.
1-24
4-24
• It is possible to come up with a checksum of the value of
10, which would require more than one digit. When this
happens, the character X is used.
• An X is only allowed in the last position.
1-25
4-25
At your seats:
• Put your names on a sheet of paper with your answers.
Turn in at the end of class to get participation credit.
• Let’s use smaller groupsize – to encourage participation.
Of course, you can always visit between groups (if
needed).
• If you cannot come to class (or choose not to), you will be
expected to complete the “super*” questions. This is a
good idea for anyone who wants to understand the
material better.
1-26
4-26
InClass: Feb 2 (groupsize≤2, unless hardship)
1.Which of the following are correct ISBN numbers?
•
•
•
•
•
0-691-12565-1
0-13-601722-4
0-393-95442-0
1-930110-89-8
Excel helps. Use Mod to get remainder. Ask TAs if you don’t know how to do this
2. Is it possible to have a nine digit code for which there is no
final digit that makes it “work”?
3. What is the last digit of this ISBN 1-243553-56-?
4. Experiment with “binary” lesson on CSILM. See webpage
for instructions on how to logon. This part can be done at
home – as there is nothing to turn in.
SUPER*: Why do you think they selected this strange formula rather
than simple parity (adding a 1 if the sum of the digits was odd)?
What are common data entry errors? Show common errors in
typing an ISBN number. Can you detect the error? Did the
1-27
checksum help? When is the concept of a self-checking code
4-27
appropriate?
Class update
• Exam FRIDAY. NO make-ups (see syllabus).
• Study session – 11-1 on Thursday, in Old Main 416
• SI session – Thursday at 5, in SER 005
1-28
4-28
How does this help?
What sort of errors might occur that wouldn’t be detected?
Can you change a digit and still get a correct checksum?
What if two digits are swapped?
Can you correct the error?
Sometimes recognizing an error is enough (error
detection) – as the data can be sent again.
• Sometimes we need to be able to reconstruct the correct
values (error correction)
•
•
•
•
•
1-30
4-30
Wouldn’t it be nice to know about the omission?
•How do I love thee? Let me count the
ways.
I love thee to the depth and breadth and
height
My soul can reach, when feeling out of
sight
For the ends of Being and ideal Grace.
I love thee to the level of everyday's
Most quiet need, by sun and candle-light.
I love thee freely, as men strive for Right;
I love thee purely, as they turn from
Praise.
I love thee with a passion put to use
In my old griefs, and with my childhood's
faith.
I love thee with a love I seemed to lose
With my lost saints, --- I love thee with the
breath,
Smiles, tears, of all my life! --- and, if God
choose,
I shall but love thee better after death.
How do I love thee? Let me count the
ways.
I shall but love thee better after death.
1-31
4-31
Another Example
Another example of the use of a check digit is the bar
codes on grocery items. This uses a different formula.
If a bar code is misread the final digit should be
different from its calculated value. When this happens
the scanner beeps and the checkout operator re-scans
the code.
1-32
4-32
Getting help
• In this chapter, we talked about finding the error ourselves.
• Sometimes we can’t find the errors ourselves.
• Suppose five letters need to be in the correct order for
something to work. How many different orders are
possible?
• 5*4*3*2*1 = 120 (called a permutation)
• Even with only five things to order, the possibilities are
large. Think what happens when you have 100 choices to
make!
• Obviously random guessing isn’t the best approach. If
we’ve tried a few things, we made need to ask someone
else.
1-33
4-33
Survey
• By the show of hands, how many have ever been treated
like they were an idiot when asking for help?
1-34
4-34
So how do you get help?
The common assumption is that the caller is clueless – so you are
fighting against that perception.
1. State the problem as clearly as possible using technical terms.
2. State what you have done to solve the problem.
3. Send them a screen shot if possible. Then they can see exactly what
you see.
– Hitting <print screen> takes a picture of the whole screen
– Holding down <alt> and then hitting <print screen> takes a picture
of the last active window (the one that is highlighted)
– Now just hold down <ctrl> while hitting v to paste it into word, an
email message, whatever. (<Right click> <paste> also works)
– On a Mac:
• Command+shift+3 creates a picture file on your desktop
• Command+control+shift+3 copies to clipboard
• Command+shift+4 captured window is saved as a file
1-35
4-35
At seats:
• Try going to CSILM.usu.edu and logging on as a <guest>
• (The document “CSILM How To” on my website explains
how.)
• See if you can run the “Binary” lesson.
• If you get there (or fail to make it run), take a screen shot
of the window, and place it in an email or word document.
We really do need to get the ILMs working. If it doesn’t, you
may not have Java installed. Click on HelpRunILM on my
webpage to see how to test for missing software.
1-36
4-36
Precision: The High Standards of IT
• Precision in Everyday Life
– Many people say "oh" rather than zero when giving a
phone number
– The listener makes the mental conversion because he
knows phone numbers are numeric
– Computer does not know that unless it has been
programmed to know it.
– How forgiving was the browser in interpreting your html
document?
– We saw examples with google, right? The computer
wouldn’t know when you type “5+3*2” you wanted the
calculator unless someone decided to teach it that.
1-37
7-37
Lexical Structures
• Field Inputs: Information entered into boxes/forms on
screen
– Governed by lexical structures (rules about the legal
form for input fields)
Lexical: of or relating to words or the vocabulary of a language as
distinguished from its grammar and construction
• May limit symbols that can appear in specific
positions, length of entry, etc.
• May also be loose, allowing any sequence of
symbols of any length
1-38
7-38
Debugging: What's the Problem?
• We talk about Debugging software, but the principle
applies to problem solving in general.
• Debugging: The method of figuring out why a process or
system doesn't work properly
– Usually learned from experience
• Debugging in Everyday Life: People troubleshoot problems
such as why their cars don't start, they can’t cook, they are
doing poorly in USU 1360…
– Not everything is broken.
• Debugging in Information Technology:
–
–
–
–
Why didn’t your webpage work?
Working system but wrong data or wrong configuration information
There might be a logical design error
We will always begin by assuming a correct, working system as it is
unlikely that everything failed at the same time
1-39
7-39
Term “debugging” came from finding a bug which was causing
the problems in an early computer.
1-40
7-40
Whose Problem Is It?
• When we debug an information system, we are
always part of the problem: Us or Them
– We give the commands and give the input
• pilot error
– Only other possibility is broken system (not as likely)
• People don't knowingly make errors – so they are
harder to find.
– misunderstand the system
– We remember things incorrectly as the error was
caused by a sequence of events, not a single event
1-41
7-41
Using the Computer to Debug
• Error is internal to the computer
– To get information about the error, we have to ask the
computer what data it stored, etc.
– get feedback
• With faulty software we cannot fix, try to bypass error with
alternative approach (workaround)
– Example: Blackboard adds students to classlist based on Banner
enrollment, but doesn’t delete them when they drop (a bug).
Disables workaround by not allowing me to delete students.
Example: Blackboard doesn’t know that an assignment has been
graded when it is uploaded from a spreadsheet (a bug).
Workaround allows me to manually move each student’s
assignment to the graded category.
1-42
7-42
A Dialog About Debugging
• Debugging is solving a mystery – frustrating, but engaging!
– Whatdunit vs. whodunit
• Ask purposeful questions like:
– Do I need more clues?
– Are my clues reliable?
– Is the behavior repeatable? – why important?
– Can I gain more information by making minor changes
and trying again?
– What is a theory to explain the problem?
• Better than aimlessly "trying stuff"
1-43
7-43
Debugging (cont'd)
•
Steps to follow:
1.
Check that the error is reproducible – especially in a smaller
sample.
2.
Make sure you know what the problem is
I transfer file to cc.usu.edu, but get the following error when I try
to view it: ERROR 404 - The requested resource could not be
found.
3.
Check all the "obvious" sources of error. When I transferred the
file, it did say there was an error.
4.
Isolate the problem
• Divide operation into those parts that are working and those
that are not working. Try something simpler.
5. Think objectively—ask yourself if you've made a wrong
assumption, etc.
6. Step back in time – when did it work?
1-44
7-44
Then…
• When you reach a dead end, reassess your information;
then step through the process again
– Ten minute rule.
– My Grandmother – If you have a fussy baby, put them in
the crib and take a ten minute breather. If the child is still
crying after ten minutes, pick him up. At that time, you
know he is really unhappy and you’ve had ten minutes to
relax and gain your composure.
– If you have spent ten minutes looking at the same
problem without success, take a break and get more info!
Students often say, “I’ve spent ten hours looking at the
problem and I can’t figure it out.” 
• Make predictions about what should happen if X was the
problem and verify it happens. If my file was bad, I wouldn’t
1-45
be able to see it on my roommate’s account either.
7-45
Text
• Your text goes through two examples of debugging.
• We won’t discuss them in class, but it is good for you to
read through them so you understand the steps.
1-46
4-46
Butterflies And Bugs: A Case Study
• Imagine we've developed a simple HTML page
• Following is our goal page:
1-47
7-47
Our Goal Page:
1-48
7-48
1-49
7-49
The Actual Display in IE:
1-50
7-50
1-51
7-51
Butterflies and Bugs (cont'd)
• Displaying the page in Safari and Mozilla also produces
errors
– Test in multiple browsers!
• We can study the HTML very closely and reason where
the error is
• We will use the debugging strategy
1-52
7-52
Butterflies and Bugs (cont'd)
• First, be sure we can re-create the error
– Reload the page
– In this case, the results are the same
• Next, determine the problem exactly
– Look at the displayed page and determine where the
errors occur
– Since there are multiple errors on different parts of the
page, assume they are caused by different mistakes in
the HTML
• Try to fix first/top error on page first; save and refresh browser
1-53
7-53
The HTML for
Our Page
1-54
7-54
Butterflies and Bugs (cont'd)
• Next, eliminate the obvious
– In HTML, most common error is forgetting to close a
tag
• For example: <b> with no closing </b> tage
– Make sure all quotes match (open and close)
• In this case, the word Blues appears in red on the page.
Why?
<caption><b><font color=blue">Blues</font>
• Missing opening quotation mark around the attribute value
"blue"
– Why is the "More here" link not highlighted?
• Space missing between <a and href
1-55
7-55
1-56
7-56
Butterflies and Bugs (cont'd)
• Divide up the process
– Separate the parts of the system that work from the
parts that do not
• First row of the table
• Browsers and debugging systems for HTML can give us a
color-coded version of the HTML, showing how it's being
interpreted (for example, Notepad++)
– View (page) source
• We see the entire heading line is colored blue as if it's an
attribute
• The problem turns out to be a fancy quote that the browser
cannot interpret
1-57
7-57
1-58
7-58
Butterflies and Bugs (cont'd)
• Reassess
– The pictures are still not displaying
– We find that the image tags are well structured and
the browser is interpreting them correctly
– What is the problem?
• To check that the images are ok, display in another
document
• To check that the JPEG specification is ok, put another
image file in the document
• Check the exact file name for the image, including
capitalization
– In this case, we find the filename extension is .jpeg, not .jpg as
we have been using
1-59
7-59
Butterflies and Bugs (cont'd)
• Unnecessary changes:
– During the debugging process, we made some
unnecessary changes due to wrong conjectures about
the error
– Making unnecessary changes is typical in debugging
• Sometimes we even make the situation worse by
introducing new errors
1-60
7-60
Butterflies and Bugs (cont'd)
• Hiding other errors:
– At first we thought we had three errors—bad caption,
missing link, busted table
– Because there were two things wrong with the table
(messed up heading line and wrong file names
specified) there were actually four errors
– Because it is common for one error to hide another,
always suspect there is more than one error
1-61
7-61
Butterflies and Bugs (cont'd)
• Viewing the source:
– Most effective technique in our debugging was the View Source
feature
– In general, one of the most powerful debugging techniques is to
find ways for the computer to tell us the meaning of the information
it stores or the commands it executes
• Little errors, big problems:
– The errors in the HTML code were tiny, but they had serious
effects
– We must be extremely precise
1-62
7-62
No Printer Output: A Classic Scenario
• Most systems we use, we don't create
• The software is very complicated. How do we
troubleshoot a system we don't understand?
• Generally, software has been extensively tested before
we come in contact with it
– Standard operations are likely to be bug-free
• To illustrate debugging a system without understanding
it, consider a common problem: You try to print a
document and nothing comes out of the printer
1-63
7-63
Applying the Debugging Strategy
• Apply the debugging strategy:
– State the problem.
– Reproduce the error, understand the problem, check
the obvious causes
– Check the printer's control panel, the paper, the
cartridges, cable connection, file to be printed,
installation of printer driver, whether others can print (if
it's a shared printer) and whether you can print a
different document
• Simple, quick checks
– If this does not solve the problem, press on
1-64
7-64
Pressing On
• Try to isolate the problem:
– Configuration is correct because you've printed before
– Try printing a simple document
• Same problem
– Think through the probable process
• If the computer couldn't send the data to the printer, wouldn't it
give a message to plug in the printer?
• Look around for the stranded files
– In the printing monitor's files, you find a list of files you've tried to
print recently
– Start > Printers and Faxes
1-65
7-65
The Print Queue
• You've found the print queue
• Computer's settings may tell it to "queue"
converted files rather than printing them
immediately
– Pause Printing
• You may never know how this occurred, but you
can still fix it by re-configuring the driver
– Unclick Pause Printing or click Resume Printing
1-66
7-66
1-67
7-67
1-68
7-68
1-69
7-69