DEV Community

Discussion on: What are your debugging tips?

Collapse
 
nikfp profile image
Nik F P

Everything everyone already said here, and:

  • Use TDD, or at least write tests as you write code. Even though this almost always starts a flame war, I have become convinced this is the way to go. How does this affect debugging? It forces you to break your design apart into manageable pieces that are easier to reason about, simply because if it's too hard to test it's also probably coupled to something else or trying to do too much. This then means that you can then debug small modules in isolation, and even take advantage of breakpoints while running test suites. (note this usually fails at least one test with a timeout, so run the suite again afterwards)