Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tonga Institute of Higher Education

Similar presentations


Presentation on theme: "Tonga Institute of Higher Education"— Presentation transcript:

1 Tonga Institute of Higher Education
Debugging Tonga Institute of Higher Education

2 Fixing Errors Bug – An error in a program
Debug - To find and remove errors (bugs) from a software program. When an error occurs, try to understand the error Try to fix the error yourself before asking for help. If you ask for help, be able to describe what's going on The more experience you have with errors, the better you will be able to fix them in the future

3 Compile Errors, Runtime Errors and Logical Errors
Compile Errors – Errors that are found during the compilation of a program Your program is unable to compile Runtime Errors – Errors that cause an abnormal termination of a program Your program crashes Logical Errors – Errors that are not found during the compilation of a program and do not cause an abnormal termination of the program These are the most difficult to find and often results in very big problems. You set an employees pay check to be $500,000 instead of $50,000

4 Common Compile Errors Parenthesis must occur in matching pairs
Error Message ')' expected. A function must specify a return type Option Strict On requires all function and property declarations to have an 'As' clause.

5 Common Compile Errors A function must return the correct type
Error Message Option Strict On disallows implicit conversions from ‘<datatype>' to ‘<datatype>'. A subroutine must not try to return something 'Return' statement in a Sub or a Set cannot return a value. Creating an overloaded method with the same signature Method ‘<MethodName>' has multiple definitions with identical signatures.

6 Common Runtime Errors Not provided a way for Loops to end
The program will run forever A function must have a return value specified. Null is returned Dividing a number by 0 Trying to access a resource that is not available

7 Task List Use the task list to quickly take you to the source of your error This only works for compile errors Double Click on this to go to the error

8 Break Points - 1 Helps keep track of the break points in your program
When the program finds a line with a break point, it will pause Some lines of code cannot have breakpoints. (Example: Comments) You can break on conditions. Right click on the break point for more options. Example: Stop when a variable x = 15 Click here to set, disable and remove breakpoints Red highlight means a break point is set

9 Break Points - 2 You can do many things while paused Examine variables
Step into a method Step over a method Step out of a method Go back to the break point Continue running the program Step into a function Step over a function Step out of a function Go back to break point Continue running the program

10 Watch Points, Locals and Autos
Displays information about variables you select to examine You must pick the information you need There are 2 ways to add a watch point Right click on a variable when the program is paused to add a watch point Type in the variable name Select the variable in the watch window and press the Delete button to remove it When a variable changes, it turns red in the watch window Locals / Autos Displays information about different variables

11 Call Stack Sometimes, we can become confused when we have many events and methods. A call stack helps us remember how we arrived at a location It lists the methods that were called to reach this point in code We can change the information we see by right clicking in the call stack We paused here Shows how we got here

12 Output Shows output from your program
Useful for outputting lots of data when debugging a program The output will not be seen by the user when the program is run Use this code to print text in the output window Debug.Writeline(“Output!”)


Download ppt "Tonga Institute of Higher Education"

Similar presentations


Ads by Google