Prevention is better than a cure
All problems are best dealt with before they actually occur and become a problem. This may sound overly simplistic or even stupid, but it is extremely true when it comes to software development. Bugs cause side effects, both on data by inhibiting it from moving through its intended life cycle, and on the reputation of the system and its developers. Anything we can do to avoid a bug being found in the wild will help us to limit and mitigate this. We won't stop all bugs, but any bugs we can stop will be a help.
The first thing I wish to advocate, therefore, is extremely thorough Apex testing. Some of you may have just groaned audibly, but I will ask you to bear with me while I explain why for me this is the first step in debugging. And if you know and have taken a Test-Driven Development (TDD) approach here, you may just be laughing.
Firstly, tests can assist in pre-empting bugs. We will discuss in Chapter 5, Testing Apex Code, why testing...