General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Advertisements

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.
1 More on Arrays and Loops Reading for this Lecture: –Section 5.4, , Break and Continue in Loops Arrays and For-each Loops Arrays and Loops.
Debugging in Matlab C. Reed 4/5/11. Bugs Debugging is a natural part of programming: Three standard types of errors: –Syntax errors: you simply have typed.
Flow Charts, Loop Structures
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
General Computer Science for Engineers CISC 106 Lecture 22 Dr. John Cavazos Computer and Information Sciences 04/13/2009.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
General Computer Science for Engineers CISC 106 Lecture 20 Dr. John Cavazos Computer and Information Sciences 04/08/2009.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
Loops – While, Do, For Repetition Statements Introduction to Arrays
Finding and Debugging Errors
Guidelines for working with Microsoft Visual Studio.Net.
General Computer Science for Engineers CISC 106 Lecture 25 Dr. John Cavazos Computer and Information Sciences 04/20/2009.
General Computer Science for Engineers CISC 106 Lecture 13 Roger Craig Computer and Information Sciences 3/13/2009.
General Computer Science for Engineers CISC 106 Lecture 34 Dr. John Cavazos Computer and Information Sciences 05/13/2009.
Visual Basic Debugging Tools Appendix D 6/27/20151Dr. Monther Aldwairi.
General Computer Science for Engineers CISC 106 Lecture 33 Dr. John Cavazos Computer and Information Sciences 05/11/2009.
General Computer Science for Engineers CISC 106 Lecture 05 Dr. John Cavazos Computer and Information Sciences 2/20/2009.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Guidelines for working with Microsoft Visual Studio 6.
General Computer Science for Engineers CISC 106 Lecture 23 Dr. John Cavazos Computer and Information Sciences 4/15/2009.
General Computer Science for Engineers CISC 106 Lecture 18 Dr. John Cavazos Computer and Information Sciences 3/27/2009.
Debugging Logic Errors CPS120 Introduction to Computer Science Lecture 6.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Python quick start guide
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
IT1005 Lab session on week 6 (2 nd meeting). Lab 2 - Recap By now, you must ensure that you are familiar with Matlab environments: – Matlab main window,
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Debugging UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
1 Debugging: Catching Bugs ( II ) Ying Wu Electrical Engineering & Computer Science Northwestern University EECS 230 Lectures.
ME 142 Engineering Computation I Debugging Techniques.
VB – Debugging Tools Appendix D. Why do we need debugging? Every program has errors, and the process of finding these errors is debugging Types of errors.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
Data Structures and Debugging Dr. Nancy Warter-Perez June 18, 2003.
ENEE150 – 0102 ANDREW GOFFIN Testing and Debugging.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Solving Systems Using Elimination
Structured Programming: Debugging and Practice by the end of this class you should be able to: debug a program using echo printing debug a program using.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
Matlab Programming for Engineers
CPS120 Introduction to Computer Science Iteration (Looping)
EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
CS 177 Week 10 Recitation Slides 1 1 Debugging. Announcements 2 2.
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 3 Friday 03 Oct 2014 EGR 115 Introduction to Computing for Engineers.
General Computer Science for Engineers CISC 106 Lecture 15 Dr. John Cavazos Computer and Information Sciences 03/16/2009.
5.01 Understand Different Types of Programming Errors
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic nd Edition.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Learning Javascript From Mr Saem
Debugging M-Files Steve Gu Feb 08, Outline What’s Debugging? Types of Errors Finding Errors Debugging Example Using Debugging Features.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
General Computer Science for Engineers CISC 106 Lecture 09 Dr. John Cavazos Computer and Information Sciences 03/04/2009.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
5.01 Understand Different Types of Programming Errors
ME 142 Engineering Computation I
Testing and Debugging.
5.01 Understand Different Types of Programming Errors
Chapter 9 Control Structures.
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
General Computer Science for Engineers CISC 106 Lecture 03
Presentation transcript:

General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009

Lecture Overview Common Errors Debugging Tips (pgs 72 – 76) Symbolic Debugger ( )

Different Kinds of Errors Syntax Errors x = (y + 3) / 2); Run-time Errors x = n / 0; Logical Errors Runs correctly but wrong answer!

Common Problems Not initializing all variables Starting array index variable at 0 Incorrect evaluation order in equation Off by one error Infinite loop

Some easy fixes Break up equation into smaller pieces Add parenthesis to make equation clear Initialize all variables!

Debugging Add print statements! Display value of all variables Run through a very simple test case Increasingly make test case longer For example, sorting an array try an empty array, try with one element, try an array of size 2, then size 5, so on…

Finding an number in array - Pass into function array and number - Initialize array index to 1 - Initialize number found boolean variable - while number not found - if current array position has num - set number found - end - If number found report!

Finding a number in an array function found = findNumber(array, value) x = 1; found = false; while (found == false) if (a(x) == value) found = true; end What is the problem?

Add some print statements function found = findNumber(array, value) x = 1; found = false; while (found == false) if (a(x) == value) found = true; end found x end Note x does not change!

Add some print statements function found = findNumber(array, value) x = 1; found = false; while (found == false) if (a(x) == value) found = true; end x = x + 1; end Problem if value not found! Should test for this.

Add some print statements function found = findNumber(array, value) x = 1; found = false; while (found == false && x <= length(a)) if (a(x) == value) found = true; end x = x + 1; end

Symbolic Debugger Open m-file to debug in Matlab editor Can set breakpoints Where you want execution to suspend Execute in command window as normal, 2009 from 1:00 PM to 1:30 PM

Symbolic Debugger Execution suspends in editor at breakpoint Can view variables in command window Can step through the code Can continue to next breakpoint 17, 2009 from 1:00 PM to 1:30 PM