Ask HN: How do you debug your code?
Data point: The amount of time I&#x27;ve spent doing &quot;debugging work&quot; has gone down VASTLY since I&#x27;ve adopted TDD. Literally, every line of debug code you will ever write (whether it&#x27;s a println buried in the code or something done in a REPL) is a potential unit test assertion.<p>What is a debug statement, anyway? You&#x27;re checking the state at a point in the code. That&#x27;s exactly what a unit test assertion does... except that a unit test calls a single method&#x2F;function... meaning the code you&#x27;re trying to debug needs to be split up and written in a way that is easily unit-testable, with few, if any, dependencies that aren&#x27;t explicitly given to it... which makes it better code that is easier to reason about (and thus results in fewer bugs).<p>See where I&#x27;m going with this? TDD = say (mostly) goodbye to &quot;debugging&quot;