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.

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Test process essentials Riitta Viitamäki,
Lecture 8: Testing, Verification and Validation
Detecting Bugs Using Assertions Ben Scribner. Defining the Problem  Bugs exist  Unexpected errors happen Hardware failures Loss of data Data may exist.
Int 2 Computing Software Development.
Why care about debugging? How many of you have written a program that worked perfectly the first time? No one (including me!) writes a program that works.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Systems Analysis, Prototyping and Iteration Systems Analysis.
Programming Types of Testing.
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
Debugging Introduction to Computing Science and Programming I.
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
Python Programming Chapter 1: The way of the program Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
CSI 101 Elements of Computing Spring 2009 Lecture #2 Development Life Cycle of a Computer Application Monday January 26th, 2009.
Systems Analysis and Design in a Changing World, 6th Edition
PRE-PROGRAMMING PHASE
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
ITM 352 © Port,KazmanDebugging - 1 ITM 352 Debugging.
Scenario testing Tor Stålhane. Scenario testing – 1 There are two types of scenario testing. Type 1 – scenarios used as to define input/output sequences.
Introduction to High-Level Language Programming
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Verification and Validation Overview References: Shach, Object Oriented and Classical Software Engineering Pressman, Software Engineering: a Practitioner’s.
Program Development Life Cycle (PDLC)
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
COMP 121 Week 1: Testing and Debugging. Testing Program testing can be used to show the presence of bugs, but never to show their absence! ~ Edsger Dijkstra.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Chapter 22 Developer testing Peter J. Lane. Testing can be difficult for developers to follow  Testing’s goal runs counter to the goals of the other.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
Making Good Code AKA: So, You Wrote Some Code. Now What? Ray Haggerty July 23, 2015.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
The Software Development Process
1 Program Planning and Design Important stages before actual program is written.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
Fixing the Defect CEN4072 – Software Testing. From Defect to Failure How a defect becomes a failure: 1. The programmer creates a defect 2. The defect.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
Intermediate 2 Computing Unit 2 - Software Development.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
Click to add text Systems Analysis, Prototyping and Iteration.
Programming Errors. Errors of different types Syntax errors – easiest to fix, found by compiler or interpreter Semantic errors – logic errors, found by.
TESTING FUNDAMENTALS BY K.KARTHIKEYAN.
The Hashemite University Computer Engineering Department
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Dynamic Testing.
Observing the Current System Benefits Can see how the system actually works in practice Can ask people to explain what they are doing – to gain a clear.
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
MOOR ERROR HANDLING Types of error How to test your code for errors How to detect errors How to recover from errors.
ITM 352 Debugging.
SOFTWARE TESTING Date: 29-Dec-2016 By: Ram Karthick.
Testing and Debugging.
Some Simple Definitions for Testing
An Introduction to Debugging
Review of Previous Lesson
Presentation transcript:

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 result, or to behave in unintended ways.

DEBUG Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected. Debugging is a necessary process in almost any new software or hardware development process, whether a commercial product or an enterprise or personal application program.

DEBUGGING PHILOSOPHY Guiding Steps: 1) Think about why you believe the program should produce the output you expected. 2) Make assertions until you understand how your view differs from the computer’s. Coder: code will produce output X … Computer: code will produce Z….

WHY DEBUGGING IS HARD There may be no obvious relationship between the external manifestation of an error and its internal cause. Symptom and cause may be in remote parts of the program. Changes (new features, bug fixes) in program may mask (or modify) bugs. Symptom may be due to human mistake or misunderstanding that is difficult to trace. Bug may be triggered by rare or difficult to reproduce input sequence, program timing (threads) or other external causes. Bug may depend on other software/system state, things others did to you systems weeks/months ago.

TYPES OF BUGS Compile time: syntax, spelling, static type mismatch.  Usually caught with compiler Design: flawed algorithm.  Incorrect outputs Program logic (if/else, loop termination, select case, etc).  Incorrect outputs Memory nonsense: null pointers, array bounds, bad types, leaks.  Runtime exceptions Interface errors between modules, threads, programs (in particular, with shared resources: sockets, files, memory, etc).  Runtime Exceptions Off-nominal conditions: failure of some part of software of underlying machinery (network, etc).  Incomplete functionality Deadlocks: multiple processes fighting for a resource.  Freeze ups, never ending processes

WHY DEBUGGING IS IMPORTANT? Debugging is the group of activities that software developers perform to fix a bug, so being a good debugger is a very important part of being a good developer. 3 reasons to consider debugging one of your main skills: We spend a lot of time debugging. By improving your debugging skills you are likely to change this balance so that you can spend more time coding new features. There are always errors in your code and you will have to debug them without introducing new errors. There are two famous quotes that illustrate this. Debugging is sometimes the only way to check that some code is working fine.

3 CONSEQUENCES OF BEING A BAD DEBUGGER Low productivity. Debugging is one of the main activities when developing software, bad debuggers will have to spend more time debugging and that will affect their productivity. Identifying error is very difficult task, errors are like icebergs: their visible part is just 10% of the problem, which is the only part that bad debuggers are going to look into, leaving the other 90% alone ready to cause some titanic catastrophe. Collateral damage. Modifying code to fix an error has the risk of generating a completely new one, bad debuggers are likely to forget about this and will create some collateral damage every time they try to fix a bug.

7 STEPS TO FIX A BUG Step 1. Identify the error. This is an obvious step but a tricky one, sometimes a bad identification of an error can cause lots of wasted developing time, is usual that production errors reported by users are hard to be interpreted and sometimes the information we are getting from them is misleading.

TIPS TO IDENTIFY ERROS See the error. This is easy if you spot the error, but not if it comes from a user, in that case see if you can get the user to send you a few screen captures or even use remote connection to see the error by yourself. Reproduce the error. You never should say that an error has been fixed if you were not able to reproduce it. Understand what the expected behavior should be. In complex applications could be hard to tell what should be the expected behavior of an error, but that knowledge is basic to be able to fix the problem, so we will have to talk with the product owner, check documentation… to find this information Validate the identification. Confirm with the responsible of the application that the error is actually an error and that the expected behavior is correct. The validation can also lead to situations where is not necessary or not worth it to fix the error.

STEP 2. FIND THE ERROR Once we have an error correctly identified, is time to go through the code to find the exact spot where the error is located, at this stage we are not interested in understanding the big picture for the error, we are just focused on finding it

Step 3. Analyze the error. This is a critical step, use a bottom-up approach from the place the error was found and analyze the code so you can see the big picture of the error, analyzing a bug has two main goals: to check that around that error there aren’t any other errors to be found, and to make sure what are the risks of entering any collateral damage in the fix. Step 4. Prove your analysis This is a straight forward step, after analyzing the original bug you may have come with a few more errors that may appear on the application, this step it’s all about writing automated tests for these areas.

Step 5. Cover lateral damage. At this stage you are almost ready to start coding the fix, but you have to cover your ass before you change the code, so you create or gather all the unit tests for the code which is around where you will do the changes so that you will be sure after completing the modification that you won’t have break anything else. If you run this unit tests, they all should pass. Step 6. Fix the error. That’s it, finally we can fix the error! Step 7. Validate the solution. Run all the test scripts and check that they all pass.

THANK YOU