Debugging Recommendations
Sometimes you run into a problem in your code. Whether it breaks during runtime or compile time, please make sure to follow these steps before asking for help:
Spend at least 10 minutes trying to figure it out for yourself...
Research...
- If you are getting a specific error message from the compiler or run-time, try googling that message. It's amazing how often others on the web have solved the same problem you are facing.
- Check out StackOverflow to see if the question has been asked and answered there.
- Check the discussion areas on Brightspace to see if any other students have run into the same problem and have found a solution.
Unit Test...
- Do you have a unit test to help isolate the problem? If not, consider writing a short unit test. Each class should have its own unit test "main" (usually in class-nameTester.java) which instantiates an object in the class, invokes the methods in the class, and tests to make sure the methods are returning the right values.
- After we have learned about JUNIT tests, you may want to write a JUNIT test for the class in question.
Try debugging on your own...
- If are not using Eclipse yet, use the Print debugger...
- Add print statements to your code to determine the control flow of your code and variable values.
- Run your code with these extra print statements to either figure out exactly what the problem is, or where you need more print statements to gather more information.
- Once you have figured out the problem, don't forget to remove all those print statements that you added.
- If we have gotten to Eclipse, use the Eclipse debugger...
- Set break points at interesting points in your code by clicking on the line number in the source code display, right mouse, and select "Toggle breakpoint"
- Run under the debugger (the spider icon) until you hit a breakpoint.
- When you hit a breakpoint look at the current value of variables to see if you can figure out what is going on.
- Don't forget to exit the debugger when you are done.
If you still can't figure it out...
Post a questions on Brightspace...
- Ask a general question and post on Brightspace.
- Wait to see if any of your peers or TA's or the professor can help. If you are solving someone elses problem, please don't post code that will solve the assignment. You may post small sections of code that address the specific problems identified, but it's better to describe the solution in words instead of posting the code itself.
E-mail a question to the Professor or TA
- Make sure the latest version of your code is pushed to gitHub
- Optionally, create a gitHub issue by filling in the issue form in the web browser.
- Send an email to the Professor and/or TA's.
- We'll answer as quick as we can.