+1 (315) 557-6473 

Programming Homework Help Tricks for Debugging

In increasing order of ease of debugging, these are the following classes of bugs.

  • Syntax errors. This can be caused by miscounting the number of brackets, missing some punctuation, or a typing mistake. Normally the compiler will point these out, and tell you the line it occurred on, but there can be some complications where the error is reported at the end of the file (normally that is due to a closing quote or end of comment marker being missing).
  • Hope it crashes. A crash bug is probably one of the easiest bugs to fix since it stops when it happens. There are a few different types of crash bugs depending on the programming language, but the most common ones are array out of bounds or accessing a null pointer. For an array out of bounds, it might be out by 1 which can happen if you create an array of length 10 and try and access the array[10] since the valid values are 0 to 9. So if you are doing a loop make sure you use < array.length for the index. If that is not the case, then the problem is probably in the code that calculates the value to use for the index. A null pointer normally indicates that you have defined the variable but have not assigned it, so check the code to determine where it is modified and see if any of those are inside a conditional that is not always taken.
  • Incorrect variable types. This is not so much a problem in Java as it will throw an exception, but can cause problems in other languages, especially in Javascript where a string may be treated as an integer or an integer may be treated as a string. Using a linter tool can help spot these type of errors before you even run the code, and can be very helpful.
  • This is the most difficult category of the bug to find, (the name is based on the Heisenberg uncertainty principle, as the bug vanishes when you look for it). Heisenbugs often show up in multi-threaded code, and a variable can change from when it is set to when it is used, and adding print statements changes the timing so the bug often disappears. If you face a heisenbug, try seeing if running the code with a single thread fixes the bug if it does then try simplifying the code that runs on the other thread and switch back to multi-threaded code until the bug reappears, and then you have an idea of what changes were made that might influence it.
  • If you need help debugging homework you have already attempted we can do that, let us know what the problem is that you are having and what you have tried already, and we can either debug it for you, or we can use a remote desktop tool so we can debug with you.

You can rely on ProgrammingHomeworkHelp.com to provide any Programming homework help you may have.


Comments
No comments yet be the first one to post a comment!
Post a comment