Sarah Diot-Girard - Debugging as an experimental science | PyData Amsterdam 2024

Learn how to debug code systematically using scientific methods. Sarah Diot-Girard explains experimental approaches, mental models, and strategies for effective debugging.

Key takeaways
  • Treat debugging as an experimental science with systematic testing of hypotheses and validation through experiments

  • Keep a debugging log to track assumptions, experiments tried, and results - similar to how scientists maintain research logs

  • Build and maintain a “mental map” of the codebase to help isolate issues and understand interactions between components

  • Focus on making debugging experiments reproducible and systematic rather than random trial and error

  • Break down complex problems into smaller, testable pieces using divide and conquer approach

  • Be explicit about assumptions and validate them systematically - don’t trust anything without verification

  • Document bugs, solutions and learnings to help prevent recurrence and assist team knowledge sharing

  • Consider temporal aspects - check when things last worked correctly and what changed since then

  • Pay special attention to side effects, mutable state, and interactions between components as common bug sources

  • Use appropriate tools (debuggers, logs, monitoring) strategically but focus on systematic problem-solving approach

  • Consider debugging as a learning opportunity to better understand the codebase rather than just fixing issues

  • Write tests to prevent bug recurrence and improve long-term maintainability, focusing on the specific issue encountered