Sooner or later, you will get stuck, annoyed, frustrated, confused, or some other form of negative emotions when your code just does not work and you don’t know why. This is normal. You can choose to handle these situations calmly and focus on trying to solve the issues. There are several ways to approach this. Here are some recommendations
Read the error messages #
The p5.js error messages are generally very helpful. Try to understand what the message says and use the reference to unpack what you might be doing wrong.
Google (or your favorite search engine) #
Rubber Duck Debugging #
We called it the Rubber Duck method of debugging. It goes like this:
- Beg, borrow, steal, buy, fabricate or otherwise obtain a rubber duck (bathtub variety)
- Place rubber duck on desk and inform it you are just going to go over some code with it, if that’s all right.
- Explain to the duck what you code is supposed to do, and then go into detail and explain things line by line
- At some point you will tell the duck what you are doing next and then realise that that is not in fact what you are actually doing. The duck will sit there serenely, happy in the knowledge that it has helped you on your way.
Works every time. Actually, if you don’t have a rubber duck you could at a pinch ask a fellow programmer or engineer to sit in.
Your own duck #
One of the top perks of choosing this beginner group is that you will get your own rubber duck to help you on your coding journey. Name them, take care of them, talk to them, you can give your duck tattoos or other decorations.
In cases when your duck is not around you, there is an online variety of the duck, DuckGPT. It is very realistic!
p5.js Guide to Debugging #
Matti and Calvin #
After you have exhausted all other options (or sometimes earlier), you can come ask help from Matti or Calvin.