AVCE ICT – Unit 7 - Programming Session 12 - Debugging.

Slides:



Advertisements
Similar presentations
Debugging ACL Scripts.
Advertisements

VCE SD Theory Slideshows By Mark Kelly Vceit.com Debugging Techniques.
Integrated Business Applications with Databases (D3) Jenny Pedler
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.
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.
Debugging Introduction to Computing Science and Programming I.
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
Section 2.4: Errors. Common errors ● Mismatched parentheses ● Omitting space after operator or between numbers ● Putting operator between operands.
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.
Lec6 P 1 CP2030 Visual Basic For C++ programmers Copyright © University of Wolverhampton CP2030 VBFC Lecture 6 Back To Index v Procedures and Parameters.
How to Debug VB .NET Code.
Debugging Logic Errors CPS120 Introduction to Computer Science Lecture 6.
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
Visual Basic Chapter 1 Mr. Wangler.
Programming Translators.
1 Chapter 9 Writing, Testing, and Debugging Access Applications.
Enhancing User Interaction Through Programming
Visual Basic: An Object Oriented Approach 5: Structured Programming.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Chapter 4: The Selection Process in Visual Basic.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Chapter 02 (Part III) Introduction to C++ Programming.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
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.
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.
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”
CS285 Visual Basic 2 Department of Computing UniS 1 Statements in Visual Basic A statement is the fundamental syntactical element of a program smallest.
Chapter 3 The Visual Basic Editor. Important Features of the VBE Alt-F11 will open the Visual Basic Editor. The Code window is to the right, Project Explorer.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Programming for GCSE Topic 4.2: Faults and Debugging T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen.
Review, Pseudocode, Flow Charting, and Storyboarding.
22/11/ Selection If selection construct.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 8 What’s Wrong with It?
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
2. Program Development Intro Programming in C++ Computer Science Dept Va Tech August 2001 ©2001 Barnette ND & McQuain WD 1 Top-Down Design:A solution method.
1 CS105 Discussion 5 – Variables and If Announcements MP 1 due on Monday Midterm 1 on Tuesday If you need a conflict, request it NOW!!
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
1 CS 106 Computing Fundamentals II Chapter 210 “Adding Controls to User Forms” Herbert G. Mayer, PSU CS Status 7/4/2013 Initial content copied verbatim.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
31/01/ Selection If selection construct.
Testing.
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.
National Diploma Unit 4 Introduction to Software Development Procedures and Functions.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
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.
Computer Programming I
Microsoft Access Illustrated
CSS 161: Fundamentals of Computing
CHAPTER FIVE Decision Structures.
Conditions and Ifs BIS1523 – Lecture 8.
If selection construct
Tonga Institute of Higher Education
Debugging Taken from notes by Dr. Neil Moore
Programming Errors Key Revision Points.
Debugging Taken from notes by Dr. Neil Moore
Chapter 3 Debugging Section 3.4
Presentation transcript:

AVCE ICT – Unit 7 - Programming Session 12 - Debugging

Error prevention This is a much better technique than “firefighting” the bugs that a program might have Try to anticipate how users will interact with your program Build the interface such that it prevents them from clicking the wrong control at the wrong time Disable them or set the visible property to false

Error detection Run the program when you change something and see if a bug appears Since VB is interpreted, it stops at a line it can’t execute You can then debug that particular line (highlighted in yellow) Such errors are called run time errors

Syntax errors VB won’t allow these! “Went I to the yesterday supermarket” Is a nonsense sentence but you can guess at the meaning VB can’t guess, you have to put the commands in the right order and use the correct spelling Syntax errors are highlighted in red

Logic errors These are often the hardest to deal with The program runs fine but it isn’t doing what you wanted The only way to deal with these errors is to know what was expected For example – work out a calculation first, run the program and make sure that the answer is the same

How to deal with errors Assuming you can’t prevent all of them…. When an error occurs, VB returns an error code e.g. 13, the type mismatch error You can use that code to deal with error using the Err function

How to deal with errors A typical error handler might be: If Err=13 Then MsgBox “Enter a whole number please” End If Error handlers can either be in the sub procedure itself as part of it, as a general procedure if you know that you might want to use it many times Or as a separate part of a sub procedure that the program branches to when an error occurs

Using the debug facilities You can set watches to observe variable values at run time You can use the Immediate window to enter values “on the fly” at run time and see how the program reacts You can execute the program by stepping into it and executing one line at a time You can set Breakpoints (marked in brown) where the program execution will stop allowing you to check values and conditions

Debugging versus good coding Good programming practice means that you prevent errors wherever possible Declare all variables and use option explicit Use local variables wherever possible Use indentation and comments This makes code easier to follow Be systematic in your testing

Your assignment To get the highest marks, you will have prevented errors or developed error handling routines You program need not be perfect – we are marking good programming and that it matches the user requirements When in doubt – keep it simple!

A few debugging thoughts You write a program to add two variables but keep getting the answer as 0 What could be the problem? I need to analyse the population statistics for Worcester I am using an Integer data type – why do I keep getting problems? My computer crashes when I run my program with a loop in it I am using an Input Box to read in a number but I keep getting the “type mismatch” error

Return to Main menu