15 Debugging

Innovation at the museum

This chapter covers

  • Reproducing a bug in code that involves primitive data types
  • Reproducing a bug in code that involves aggregated data
  • Replaying a scenario in the REPL
  • Creating unit tests from bugs

When our programs don’t behave as expected, we need to investigate the source code. The traditional tool for code investigation is the debugger. The debugger allows us to run the code, step by step, until we find the line that causes the bug. However, a debugger doesn’t allow us to reproduce the scenario that causes the problem.

In DOP, we can capture the context of a scenario that causes a bug and replay it in a separate process like a REPL or a unit test. This allows us to benefit from a short feedback loop ...

Get Data-Oriented Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.