I see unit tests as the playground where code learns to behave.
We want reusable code. Being easily unit testable is proof that the code can work in two contexts. As soon as you use the unit outside the test, you are already reusing it.
Design pressure from driving development with tests is like the training kids get from play. We teach the code how to interact with others, experiment with interfaces, boundaries and naming.
When we have code that works well in a unit test (and no, if you need a fancy testing framework the code is not behaving well enough ) we can let it play with the rest of the production code.
If it is a pain to test, it will be a pain to use, maintain and debug. So play with the code a bit first, it will be worth it.
Comment on the blog!
Create a comment by emailing me. I will then add the comment to the post.Open an email to start writing.