2 Understanding your app’s logic through debugging techniques

 

This chapter covers

  • When to use a debugger and when to avoid it
  • Using a debugger to investigate code
  • Enhancing your debugging techniques with AI assistants

Not long ago, during one of my piano lessons, I shared the sheet music of a song I wanted to learn with my piano teacher. I was so impressed when he just played the song while reading the music sheet for the first time. “How cool is that?” I thought. “How does someone gain this skill?”

Then, I remembered some years ago I was in a peer-programming session with one of the newly hired juniors in the company I was working for. It was my turn at the keyboard, and we were investigating a relatively large and complex piece of code using a debugger. I started navigating through the code, pressing relatively quickly the keyboard keys that allowed me to step over, into, and out of specific lines of code. I was focused on the code but was quite calm and relaxed, almost forgetting I had someone near me (rude of me). I heard this person say, “Wow, stop a bit. You’re too fast. Can you even read that code?”

2.1 When analyzing code is not enough

2.2 Investigating code with a debugger

2.2.1 What is the execution stack trace, and how do I use it?

2.2.2 Navigating code with the debugger

2.3 When using the debugger might not be enough

2.4 Summary