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

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Introduction to the SPL Interpreter
Chapter 8 Improving the User Interface
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.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
BIM313 – Advanced Programming Techniques Debugging 1.
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
Ten debugging techniques. The execution process Execution proceeds in a standard series of steps Compute values of subexpressions first Then call value.
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.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Visual Basic Debugging Tools Appendix D 6/27/20151Dr. Monther Aldwairi.
Debugging Logic Errors CPS120 Introduction to Computer Science Lecture 6.
Using a Debugger. SWC What is ”debugging”? An error in a computer program is often called a ”bug”… …so, to ”debug” is to find and get rid of errors in.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
The NetBeans IDE CSIS 3701: Advanced Object Oriented Programming.
Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation.
InDesign CS3 Lesson 4 ( Only pages ) Importing and Editing Text.
BİL528 – Bilgisayar Programlama II Making Decisions, Loops, Debugging, Designing Objects Using Classes 1.
Object Oriented Software Development 8. Exceptions, testing and debugging.
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.
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.
ArcObject. Chapter 8 Chapter 7: Coding a For loop A For loop begins with the For keyword and ends with the Next keyword. The For keyword on the first.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
CS320n –Visual Programming More LabVIEW Foundations.
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.
Review while loops Control variables Example Infinite loop
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
Georgia Institute of Technology Creating Classes part 2 Barb Ericson Georgia Institute of Technology June 2006.
5.01 Understand Different Types of Programming Errors
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
Debugging What coders (programmers) do to find the errors (“bugs”) in their own programs “Bugs” – Admiral Grace Hopper, developer of the world’s first.
IMS 3253: Validation and Errors 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Validation and Error Handling Validation.
Debugging No readings. 2 What's The Proper Indentation? function max(x,y) { if (x
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Excel Tutorial 8 Developing an Excel Application
Appendix A Barb Ericson Georgia Institute of Technology May 2006
A variable is a name for a value stored in memory.
Chapter 2: The Visual Studio .NET Development Environment
5.01 Understand Different Types of Programming Errors
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Eclipse Navigation & Usage.
Testing and Debugging.
Computer Programming I
CHAPTER FIVE Decision Structures.
CHAPTER FIVE Decision Structures.
5.01 Understand Different Types of Programming Errors
Test Automation For Web-Based Applications
Tonga Institute of Higher Education
Introduction to TouchDevelop
Debugging Taken from notes by Dr. Neil Moore
Debugging Taken from notes by Dr. Neil Moore
Workshop for Programming And Systems Management Teachers
Presentation transcript:

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

Essential Standard and Objectives Essential Standard 5.00 Apply Programming Logic Indicator 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.

Debugging So your program is all written- but it does not work! What’s next?  This process is called debugging. There are two types of debugging- programmer debugging (fixing errors) or program debugging (allowing for unexpected input from a user)

Break Point A break point is a tool used by a programmer to isolate a section of code and watch how the complier steps through it.  This is often used with a IF statement or loop code.  Break Point example.

Adding a BreakPoint There are two ways to add a breakpoint 1. Right-click on the line of code > BreakPoint > Insert BreakPoint 2. Click in the grey vertical bar to the left of your code window.

Adding a BreakPoint A red dot will appear in the grey bar and the text will be highlighted in red. The breakpoint will be “active” when you execute and the compiler reaches that line of code.  A yellow arrow will appear in the red dot.  The line of code will be highlighted in yellow.

Using a Break Point In the example below the program has reached the breakpoint. The program will stop ( break ) and wait on the coder. The program is now controlled by the debugging controls.

Debugging Controls There are 6 tools here.  Green arrow (play): execute the rest of the program without stopping  Pause- stop here  Blue Square- stop the program and return to the IDE  Step Into- move to the next line of code in the programming block  Step Over- skip the current programming block  Step Out- exit the current programming block

The Watch Window Another tool is the watch window. This works only with the debugger is in break mode (at a breakpoint). The watch window allows the coder to track the value of variables as the program is being executed. This is useful way to catch logic errors that might otherwise be missed.

Watch Window Once in Break Mode, the Watch Window will be displayed. If it does not open, you can open it.  Debug  Windows  Watch  Watch 1 (up to 4 can be open)

Watch Window You can hover your cursor over variables in your editor window to see a popup window of the value. To add variables to the Watch Window  Right Click on the variables you want to “watch”.  Select Add Watch.  The variable is added to the Watch Window.

Watch Window You can now step through your program and see how the values of your variables change. Note how the line currently executing is highlighted and the values in the Watch window are red.

Locals Watch Window There is an automatic Watch Window called Locals. Access it by clicking on the tab at the bottom of your IDE. Or Debug > Windows > Locals

Debugging User Input Good programmers make sure their programs can handle all exceptions.  One of the most common exceptions is bad/incorrect user input For example: a field that asks for numbers (like an age) but the user enters the string “apple.” The program will fail or produce unexpected results unless this error is handled.

Try..Catch Try..Catch is a function to check for incorrect user input. Basic format Try Line(s) of code to check for exceptions Catch ex As Exception What to do if an exception is found. Generally use a message box to alert the user Finally (optional) Run this code if an exception is found or not End Try //End of the Statement

Example of Try..Catch A user needs to input their age into a text box. Ensure that only numbers are typed into this box. Try intAge = Convert.ToInt32(txtAge.Text) MessageBox.Show("Your age is: " & intAge) Catch ex as exception MessageBox.Show("Enter your age in digits!"); End Try

Message Boxes Alerting the user of an error is often done using message boxes as shown in the previous example. Basic format: MessageBox.Show(“Message”) There is no limit to the number of message boxes that can be used in a program.

Alternative Way In VB there is an alternative way to check for proper input if the value is supposed to be a number. IsNumeric is a function used with an IF statement.  It returns True if it finds a number, otherwise False. Example If IsNumeric(intAge) Then Perform some code Else MessageBox.Show(“Enter Numbers!”) End If

Wrapping it Up In this lesson you learned how breakpoints, watch window, and try..catch work and can be used for debugging.