DEV Community

loading...

Discussion on: Debug Like a Champion

Collapse
mortoray profile image
edA‑qa mort‑ora‑y

I very rarely, if ever, do step debugging or conditional watchpoints anymore. I used to do them, but somehow I've found this process of debugging is actually rather time consuming.

One of my primary methods for debugging is writing more unit tests. Anytime I have an idea, or suspicion, about the error I write a test that tries to emulate it. One great advantage to this approach is that my debugging time isn't lost, it's all encoded in unit tests that will remain with the project.

Of course, that doesn't always work. Catching thrown exceptions in a debugger is something I do often to figure out where an error is happening. I don't step at that point, I just inspect the code. This approach works well if you pepper your code with lots of runtime checks -- anything that even remotely smells funny should raise an alarm of some kind.

Collapse
pedes profile image
Andres Cespedes Morales Author

Thanks for your feedback Eda.

The debugging process is from time to time just a time-consuming activity with no results, but there are some cases as you mentioned that you need to figure out a runtime exception that may occur due to a bad development or a wrong architecture.

This is just an additional tool in the problem-solving process.