Testing is the shortest path to quality code
The last best practice we will discuss is this statement: testing is not an overhead or a burden; it is the programmer’s guide to success. The only question is when to write the test.
There is a compelling argument that requires writing a test before any line of code is written. If you can do it, that is great. We are not going to try and talk you out of it. But if you do not do it, try to start writing a test after you have written one, or all, the lines of code you have been tasked to write.
In practice, many experienced programmers find it helpful to start writing testing code after some of the new functionality is implemented. This is because that is when the programmer understands better how the new code fits into the existing context. They may even try and hardcode some values to see how well the new code is integrated with the code that calls the new method. After making sure the new code is well integrated, the programmer...