Testing and TDD
No matter how good a developer is, they'll write code that doesn't always perform correctly. This is unavoidable, as no developer is perfect. But it's also because the expected results are sometimes not the ones that one would think of while immersed in coding.
Designs rarely go as expected and there's always a discussion going back and forth while they are being implemented, until refining them and getting them correct.
Everyone has a plan until they get punched in the mouth. – Mike Tyson
Writing software is notoriously difficult because of its extreme plasticity, but at the same time, we can use software to double-check that the code is doing what it is supposed to do.
Be aware that, as with any other code, tests can have bugs as well.
Writing tests allows you to detect problems while the code is fresh and with some sane skepticism to verify that the expected results are the actual results. We will see during...