chapter two

2 Understanding your app’s logic through debugging techniques

 

This chapter covers

  • Using a debugger to investigate code
  • When choosing to use a debugger and when avoiding it

Not long ago, during one of my piano lessons, I shared a music sheet of one of the songs I wanted to learn with my piano teacher. I was so impressed when I saw him just play the song while reading the music sheet for the first time. “How cool is that?” I thought. “How could someone get 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 the debugger. I started navigating through the code using the debugger, pressing relatively fast on the keyboard keys that would allow me to step over, into, and out of specific lines of code. While I was focusing on the code I was investigating, but quite calm and relaxed, almost forgetting I had someone near me (rude of me), I heard her saying, “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 to use it?

2.2.2 Navigating code with the debugger

2.3 When using the debugger might not be enough?

2.4 Summary