As the saying goes, test happens. Sometimes it happens because the developer writes and runs the tests at the same time he's writing the code. When this happens, bugs get found quickly. And they fixed quickly, when it's cheap and easy. Life is good.
Sometimes, it happens when the code gets thrown over the wall to the QA department. This might be a few days later. In some shops, it might be weeks or months later. By that time, the developer who wrote the bug has probably forgotten everything about the code and has to spend time getting ...