Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley An Introduction to Debugging To Err is Human lawrence snyder c h a p t e.

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Test process essentials Riitta Viitamäki,
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Chapter 7: Introduction to Debugging TECH Prof. Jeff Cheng.
Announcements Wednesday's test will be postponed until Thursday – July 7 th, See me if this won’t work for you. Project 1 will be due Monday – July.
1 Chapter Overview Understanding Printer Administration Managing Printers Managing Documents Administering Printers Using a Web Browser Troubleshooting.
The Information School of the University of Washington Oct 9fit debug1 Debugging and Troubleshooting INFO/CSE 100, Fall 2006 Fluency in Information.
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
XP 1 Designing a Web Site with Frames Using Frames to Display Multiple Web Pages Tutorial 5.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 11 1 Microsoft Office Excel 2003 Tutorial 11 – Importing Data Into Excel.
Chapter 7 To Err Is Human: An Introduction to Debugging.
Create a Web Site with Frames
Conversational Computers
XP Tutorial 5New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Designing a Web Site with Frames Using Frames to Display Multiple Web Pages Tutorial.
Microsoft ® Office Word 2007 Training Mail Merge II: Use the Ribbon and perform a complex mail merge [Your company name] presents:
HTML and Designing Web Pages. u At its creation, the web was all about –Web pages were clumsily assembled –Web sites were accumulations of hyperlinked.
I have attached a file to this by selecting the paperclip on the bottom of the page.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Chapter 7 To Err Is Human: An Introduction to Debugging.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
INTRODUCTION TO DREAMWEAVER 8. What we already know…  Design basics  Contrast  Repetition  Alignment  Repetition  HTML.
Learning Objectives Explain how ordinary precision differs from computing precision Describe the six-step strategy for debugging Explain the purpose of.
Topics Introduction Hardware and Software How Computers Store Data
Chapter 8: Systems analysis and design
Encoding, Validation and Verification Chapter 1. Introduction This presentation covers the following: – Data encoding – Data validation – Data verification.
Introduction to Python
The Bean Counter: A JavaScript Program
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS Dr. Zhizhang Shen Chapter 7: What Went.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
General Programming Introduction to Computing Science and Programming I.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Mail merge I: Use mail merge for mass mailings Perform a complete mail merge Now you’ll walk through the process of performing a mail merge by using the.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
Debugging & Troubleshooting “To err is human, but it takes a computer to really foul things up” © 2004 Lawrence Snyder.
XP 1 Microsoft Word 2002 Tutorial 1 – Creating a Document.
Unit 2, cont. September 12 More HTML. Attributes Some tags are modifiable with attributes This changes the way a tag behaves Modifying a tag requires.
DEBUGGING. BUG A software bug is an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected.
Algorithms CS139 – Aug 30, Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid.
Systems Life Cycle. Know the elements of the system that are created Understand the need for thorough testing Be able to describe the different tests.
Chapter 33 Troubleshooting Windows Errors. STOP Errors  When Microsoft Windows XP encounters a serious problem  And the operating system can't continue.
Chapter 6 An Introduction to Debugging. Learning Objectives Explain how ordinary precision differs from computing precision Describe the six-step strategy.
Created by, Tom Rebold, MPC FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
The Information School of the University of Washington 13-Oct-2004cse debug1 Debugging and Troubleshooting INFO/CSE 100, Spring 2005 Fluency in Information.
Conditional Statements.  Quiz  Hand in your jQuery exercises from last lecture  They don't have to be 100% perfect to get full credit  They do have.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Algorithms CS280 – 10/20/05. Announcement  Part 1 of project 2 due.  Read chapters 10, 7 for this unit  Tuesday we will also be in the classroom We.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley What did we learn so far? 1.Computer hardware and software 2.Computer experience.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Text2PTO: Modernizing Patent Application Filing A Proposal for Submitting Text Applications to the USPTO.
Revised June 2008 Online PD Basic HTML1 Let’s Try It!  Open Notepad oStart > All Programs > Accessories > Notepad oDon’t get WordPad by mistake – won’t.
DATA TYPES.
Development Environment
Testing and Debugging.
CSC 110 – Fluency in Information Technology Chapter 7: An Introduction to Debugging Dr. Curry Guinn.
Fluency with Information Technology
Intro to PHP & Variables
Designing and Debugging Batch and Interactive COBOL Programs
To Err Is Human: An Introduction to Debugging
Tonga Institute of Higher Education IT 141: Information Systems
An Introduction to Debugging
Tonga Institute of Higher Education IT 141: Information Systems
The Troubleshooting theory
Presentation transcript:

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley An Introduction to Debugging To Err is Human lawrence snyder c h a p t e r 7

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-2 Precision: High Standard in Computing 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

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-3 Exactly How Accurate Is "Precise?" Modem or database software can be programmed to make "oh" to zero corrections automatically because all digits will always be numbers In programs, both letters and numbers are allowed, so the computer can't be programmed to auto-correct. Users have to be careful Being exact can save time and frustration

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-4 Lexical Structures Field Inputs: Information entered into boxes/forms on screen –Governed by lexical structures (rules about the legal form for input fields) 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

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-5 Debugging: What's the Problem? 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 –Usually involve well-designed system with broken, worn-out part Debugging in Information Technology: –Working system might have wrong data or wrong configuration information, or –There might be a logical design error –We will always begin by assuming a correct, working system

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-6

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-7 Whose Problem Is It? When we debug an information system, we are always part of the problem –We give the commands and the input Operator or pilot error –Only other possible cause is broken system People don't knowingly make errors –We may think we did everything right because we misunderstand the system

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-8 Using the Computer to Debug A computer can't debug itself We can't debug it directly, either Error is internal to the computer –To get information about the error, we have to ask the computer what data it stored, etc. With faulty software we cannot fix, try to bypass error with alternative approach (workaround)

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-9 A Dialog About Debugging Debugging is solving a mystery –Whatdunit vs. whodunit Ask purposeful questions like: –Do I need more clues? –Are my clues reliable? –What is a theory to explain the problem? Better than aimlessly "trying stuff"

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-10 Basic Debugging Strategy 1.Check that the error is reproducible 2.Make sure you know what the problem is If no mailing labels come out of printer, problem may be with printer or with program sending labels to printer or file containing addresses

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-11 Basic Debugging Strategy (cont.) 3.Check all the "obvious" sources of error 4.Isolate the problem Divide operation into those parts that are working and those that are not working Think objectively—ask yourself if you've made a wrong assumption, etc. When you reach a dead end, reassess your information; then step through the process again As you work through, make predictions about what should happen and verify that they are fulfilled (or not) Take nothing for granted… you may assume away the error

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-12 Butterflies And Bugs: A Case Study Imagine we are developing a simple XHTML page, information on endangered butterflies Our intention is the screen shown following However, something is not right… we get different erroneous views when the page is rendered in some popular browsers

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-13 Our Goal Page

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-14 Safari Browser Display

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-15 Firefox Browser Display

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-16 Chrome Browser Display

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-17 Butterflies and Bugs (cont'd) The XHTML source for the page is shown following We can study the XHTML very closely and "brain out" where the error is Or… we can apply our basic debugging strategy

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-18 The HTML for Our Page

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-19 The HTML for Our Page (cont'd)

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-20 Butterflies and Bugs (cont'd) First, be sure we can re-create the error –Reload the page (here, the results stay the same) Next, determine the problem exactly –View the page and determine where the errors occur table without pictures skewed table entries Links not highlighted, colors not showing –Since there are multiple errors on different parts of the page, we suspect they are caused by different mistakes in the XHTML

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-21 Butterflies and Bugs (cont'd) Next, eliminate the obvious –In XHTML, common error is forgetting to close a tag For example: with no closing tag In this case, all tags match Make sure all string quotes match too (open and close) –Check for missing spaces (create unknown tags) Why is the "More here" link not highlighted? Space missing between <a and href –Why is the “Blues” word not blue? Check color specification section span.b {color ; blue} should be colon, not semi

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-22 Butterflies and Bugs (cont'd) Can try a checking tool like the Validator Not a bad idea, but often is not helpful –Won’t find design flaws –Easily confused when more than a 1 or 2 syntax errors (this page does not have errors)

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-23 Butterflies and Bugs (cont'd) OK, two bugs down, one to go (we think) First colored row of the table looks strange but not sure why Maybe related to the images not displaying in the table Check the tag for correct image file names They are correct… so backup and reassess

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-24

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-25 Butterflies and Bugs (cont'd) Divide up the process –Separate the working from the not working (as best we can) –Here, most of the page looks fine, the table is not –Concentrate on top row of table… we compare intent to what we see, and notice an entire row is missing (the headers) –Zero in on headings specifications in XHTML

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-26 Butterflies and Bugs (cont'd) –We pore over the XHTML source in detail but don’t see an error –Browsers and debugging systems for XHTML can give us some help/clues with these details For example, try Source View in Firefox (shown following) See a color-coded version of the XHTML syntax, showing how it's being interpreted –We see the entire heading line is colored blue as if it is an attribute –Then we notice a fancy quote character that the browser cannot interpret, so a string is not closed

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-27

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-28

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-29 Butterflies and Bugs (cont'd) Reassess and keep going –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 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 Bingo… we find the filename extension is.jpeg, not.jpg as we have been using

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-30

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-31 Butterflies and Bugs (postmortem) Unnecessary changes (are ok) –We fixed the page by making conjectures, try changes, run experiments, draw conclusions –During the 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, but we backup and reassess

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-32 Butterflies and Bugs (postmortem) 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

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-33 Butterflies and Bugs (postmortem) Viewing the source: –Best tool in our debugging was the View Source feature –In general, we 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 XHTML code were tiny, but had serious effects –We must be extremely precise

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-34 No Printer Output: A Classic Scenario Most systems we use, we don't create 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

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-35 Applying the Debugging Strategy –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

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-36 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

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-37 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

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-38 Software Reliability Our digital society has computers controlling significant critical resources –banks, planes, nuclear reactors, weapons, medical Errors in software can have serious consequences –injury, death, economic havoc NO software is perfect (even in safety-critical systems) What are the ways a system can fail?

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-39 Safety-Critical Systems Hardware failures –Redundancy can mitigate these 3 computers all perform the same computations, vote on correct values and look to see if they all agree 1 failure will be detected by the voting and ignored (What if voting mechanism contains the failure?) –Burn-in can mitigate these Infant mortality: if hardware fails, it is usually very early in its lifetime Use hardware that has run successfully for a test time –We can gain confidence that hardware will work correctly

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-40 Safety-Critical Systems Software failures –Software is hugely complex compared to mechanical and electronic physical systems Number of possible reachable configurations grows exponentially with increasing program size Impossible to examine all possible states –How do we gain confidence in correct execution then? –Start with precise specification of what outputs are expected for particular inputs (program design) –Test program behavior to see if it matches specs

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-41 Software Testing: The Reality Not possible to determine if specs are correct –same problem we have with programs, just pushed “up a level” in abstraction Testing can only reveal the presence of bugs, never the absence of bugs –We can test a long time and may not find the last bug –Testing brings increased confidence, not certainty

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-42 The Software User’s Challenge We must accept that software will contain errors and watch during use for unusual behavior that could reveal unfound bugs –Be prepared to limit the harm unfound bugs might cause Poorly tested software is unprofessional practice on the part of developers –Users should demand high quality and be prepared to switch to better programs

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-43 Fail-Soft vs. Fail-Safe Software Since correctness is near-impossible, we can concentrate our concerns on safety –Will a failure cause reactor meltdown? –Will a failure cause patient harm? Fail-soft means a program keeps running when errors occur, but at some reduced level of functionality Fail-safe means a program stops functioning on failure to avoid potential harms Perfectly safe software is as elusive as perfectly correct –All software-controlled systems bring some risk

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 7-44 Summary Standards of precision are higher in computing than in most other situations Learned what debugging is, why we need it, and how to do it Learned the basic debugging strategy Web page debugging involves comparing the source view of the HTML to how the browser interprets it Learned how to analyze our debugging performance Debugging involves both correct and incorrect conjectures The basic strategy allows debugging something we know little about It is impossible to have bug-free software