Troubleshooting &

De-bugging

06–A: Introduction and Learning Outcomes

Troubleshooting is a systematic approach to solving a problem is troubleshooting while applying troubleshooting techniques to programming is called de-bugging. Both are important skills to build while learning to program., since programmers regularly need to write their code in a way that allows them to find problems, reproduce them consistently, and correct them easily.

In this chapter, you will learn the basics of how to write your code and fix it on your own. Of course, if all else fails, always ask for help!

Learning Outcomes:

  1. State the difference between troubleshooting and debugging.

  2. Explain why learning to debug is important while programming.

  3. Describe the difference between warnings and errors in R and steps to take when identifying each.

  4. Recall steps to take to troubleshoot and debug problems independently, before asking for additional help.

06–B: Warnings versus Errors in R

Video (3:50)

06–C: Clearing your Global Environment in R

Video (0:27)

06–D: Common Mistakes and Steps to Fix Errors

  1. Read the error message, what does it want you to do?

  2. Check for open brackets, misspellings and typos, incorrect path names, un-installed packages, and other common mistakes.

  3. Google the error message. What are common fixes?

  4. Make sure your code is readable and in manageable "chunks". Often the error message will indicate a code chunk name if used, or the line of code where the code failed. Focus on this part.

  5. Reproduce the error consistently. Do you only see the error message in certain cases? When does the code break?

  6. If you are in the UMD PSYC300 class, check the FAQ board. Your problem may already have an answer there.

  7. Review the video 'Common Issues in R' in Ch. 5

  8. Ask for help!

References

  1. Chapter image made using with Canva ©2021 https://www.canva.com/

  2. Horst, A. Debugging. https://github.com/allisonhorst License CC-BY-SA 4.0