Week 6- Debugging Flashcards
What is debugging?
Debugging is searching a program’s source-code to find the cause of an error and then correcting the code so that the error is removed.
What is tracing?
Tracing is about discovering the order in which various program statements are carried out while the execution happens.
What is watching?
Watching is about inspecting the values of various program variables while the execution happens.
How can JavaScript alert boxes be used to trace program execution?
By placing alert boxes in the program. As the program runs any alert box that does not show up indicates that there has been an error in the coding.
How can the JavaScript alert boxed be used to watch program execution?
To do this, devise a statement that will create an alert box with a convenient message that displays the data value or values that you want to see at this point
What are the dangers of using JavaScript alert boxes as simple debugging tools?
The alert boxes may create code or outcomes that are seen by the end user. And it is also very time consuming, adding in alert boxes at different stages and removing them again.
Why is it important to tidy up source-code after debugging is finished?
Removes all the code and alerts that may be left for the end user. This can impact software performance and customer satisfaction.
What are two possible ways to tidy up debugging statements?
- Remove the debugging statements from the code (careful not to remove additional code)
- Make the debugging statements non-executable by converting them into comments. For example:
// alert (“DEBUG “ + “inside loop: “ + “counter = “ + counter + “:sum = “ + sum);
What are two possible ways to tidy up debugging statements?
- Remove the debugging statements from the code (careful not to remove additional code)
- Make the debugging statements non-executable by converting them into comments. For example:
// alert (“DEBUG “ + “inside loop: “ + “counter = “ + counter + “:sum = “ + sum);
What is a break point?
Breakpoints tell the debugger it should break, or pause code execution, at a certain point. You can set a breakpoint anywhere in your JavaScript code, and the debugger will halt code execution when it reaches the breakpoint.
What are the three ways to ‘step through’ code?
Step Into executes the next line of code. If that line is a function call, the debugger executes the function and halts at the first line of the function.
Step Over, like Step Into, executes the next line of code. If that line is a function, Step Over executes the entire function and halts at the first line outside the function.
Step Out returns to the calling function when you are inside a called function. Step Out resumes the execution of code until the function returns. It then breaks at the return point of the function.