VCE SD Theory Slideshows By Mark Kelly Vceit.com Debugging Techniques.

Slides:



Advertisements
Similar presentations
VCE IT Theory Slideshows By Mark Kelly Vceit.com Referential Integrity in databases.
Advertisements

IT Applications Theory Slideshows By Mark Kelly McKinnon Secondary College Vceit.com Design tools (not including tools for Database or Website Design or.
Coding and Debugging. Requirements and Specification Recall the four steps of problem solving: Orient, Plan, Execute, Test Before you start the implementation.
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
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.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
Debugging CPSC 315 – Programming Studio Fall 2008.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
How to Debug VB .NET Code.
Computer Science 1620 Programming & Problem Solving.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Programming Translators.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Structured programming 4 Day 34 LING Computational Linguistics Harry Howard Tulane University.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
HOMEWORK REVIEW This is an if else statement layout if (condition) { code to be executed if condition is true; } else { code to be executed if condition.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
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.
ME 142 Engineering Computation I Debugging Techniques.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
VCE IT Theory Slideshows By Mark Kelly Vceit.com Problem Solving Methodology 3 Development.
1 Program Planning and Design Important stages before actual program is written.
Debuggers in Python. The Debugger Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
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.
CS 177 Week 10 Recitation Slides 1 1 Debugging. Announcements 2 2.
VCE IT Theory Slideshows by Mark Kelly study design By Mark Kelly, vceit.com, Begin.
Testing.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Debugging What coders (programmers) do to find the errors (“bugs”) in their own programs “Bugs” – Admiral Grace Hopper, developer of the world’s first.
VCE IT Theory Slideshows by Mark Kelly study design By Mark Kelly, vceit.com, Begin.
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Harvard Mark I Howard Aiken was a pioneer in computing and a creator of conceptual design for IBM in the 1940s. He envisioned an electro-mechanical computing.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Implementation Topics Describe –Characteristics of good implementations –Best practices to achieve them Understand role of comments Learn debugging techniques.
ME 142 Engineering Computation I
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Testing and Debugging PPT By :Dr. R. Mall.
7 - Programming 7P, Q, R - Testing.
Testing and Debugging.
Lesson Outcomes Be able to identify differentiate between types of error in programs Be able to interpret error messages and identify, locate.
Chapter 15 Debugging.
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
Tonga Institute of Higher Education
Chapter 15 Debugging.
Chapter 11: Debugging.
Debugging “Why you were up till 2AM”
Software Development Process
Debugging Taken from notes by Dr. Neil Moore
An Introduction to Debugging
Perl Programming Dr Claire Lambert
Review of Previous Lesson
Chapter 15 Debugging.
WJEC GCSE Computer Science
Chapter 9: Implementation
Chapter 15 Debugging.
Presentation transcript:

VCE SD Theory Slideshows By Mark Kelly Vceit.com Debugging Techniques

Contents Origin Why debug? Techniques Test data IN PROGRESS 6 Feb 2012…

The original debugging Often said to have begun with Admiral Grace Hopper in the 1940s. While she was working on a Mark II Computer at Harvard University, her associates discovered a moth stuck in a relay which stopped it working. Removing the moth amounted to "debugging" the system.

The first bug

But, to ruin a good story The use of bug for a system fault had been since the days of Thomas Edison.

What is debugging? The process of finding and fixing errors in programming. Error types: – Syntax errors – Logical errors – Runtime errors

Syntax errors When the source (human-readable) code is not presented in a format that the compiler or interpreter can understand For example: – PRONT Hello (mistyped keyword) – PRINT Hello (punctuation error) – RND(0) instead of RAND(0) or RANDOM (wrong keyword)

Syntax Errors Very easy for a compiler/interpreter to find and tell you about Usually easy for you to fix

Logical Errors The source codes format and punctuation is correct, but it does not produce the expected answer Usually a fault of the algorithm – the method of calculation Since no warnings appear, logical errors go undetected without extensive testing

Logical errors E.g. Wanting to increase a number by 10% Using this: X = X + 10% Actually adds 0.1 to X. Needed X = X + (X*10%)

Runtime errors Syntax is perfect Logic is correct Something bad occurs during execution, e.g. – Lost network connectivity – Jammed printer – Running out of memory or disk space – Operating system failure

Analogy Syntax error: trying to board a bus through the exhaust pipe Logical error: getting on the wrong bus Runtime error: the bus breaks down

Debugging Techniques Use modular programming (more later) to reduce the amount of code you have to wade through. Inspect the values of variables line by line until the fault appears (e.g. DEBUG PRINT Value is & X Set breakpoints to pause execution and let you inspect values

Debugging tools Different IDEs (integrated development environments) offer different debugging tools – Dedicated external debugger – Breakpoints – Single-stepping – Immediate window for inspecting values – Step into/over code – Compiler reports

Debug Reduce the amount of active code remming out code (converting it to comments) to isolate the faulty code. Use MSGBOX statements to show program flow (which parts of code are being executed). You might assume a module or branch of an IF statement is executing whereas its not even getting that far. Use DEBUG PRINT to show values during execution

Debugging Look for patterns. Code often includes similar lines but one might be subtly different which highlights the error. Use code indenting so missing or misplaced parts of structures, loops etc are highlighted. Be persistent and logical and detailed. Code walk-through (desk-checking) line by line

Assert Programmers tend to assume incoming values are right (e.g. a positive integer) Assert is debugging code (removed during compilation) that checks these assumptions are true For example…

Asserting yourself Function myFunction (x as Long, y as Long Debug.Assert (x<>0 And y<>0) myFunction = 1/x + 1/y End Function If it turns out that X=0 or Y=0, the DEBUG.ASSERT statement turns out to be false, and it warns you that your assumptions about X and/or Y are false. If the DEBUG.ASSERT statement is true, execution proceeds normally.

Preventative measures Initialise variables explicitly Use meaningful variable names Use plenty of useful internal documentation to explain the codes workings Dont just assume values or parameters are correct when they arrive. Test them. Treat objects and properties carefully according to their type.

Algorithms Compare Google Page Rank algorithm with the inaccurate algorithms used before it Compare shell sort algorithm with bubble sort Compare searching with hash codes with a line-by-line search Compare sorting with an index and sorting by swapping values in an array.

Test data Used to test code Deliberately designed to expose faults or weaknesses in code Contains typical, unusual and bad data to test software behaviour and reactions Should test all possible data ranges

Boundary Conditions Most logical errors happen here At a boundary, program behaviour should change, e.g. if less than 18, you cant drink But equal to and over 18, can drink Be careful with =, > Many logical errors in exams are like this Test data should test for boundary value (e.g. 17,18,19)

By Mark Kelly These slideshows may be freely used, modified or distributed by teachers and students anywhere on the planet (but not elsewhere). They may NOT be sold. They must NOT be redistributed if you modify them. VCE IT THEORY SLIDESHOWS