Understanding when to make some of these improvements
It should be fairly obvious from reading through this chapter that for every improvement we make for one governor-constrained resource, we negatively impact another governor-restrained resource. A prime example is that without for
loops, we were able to not only dramatically improve CPU time usage but also increase our heap size usage. So when should we make these improvements and implement some of the items we have seen?
The short answer is, it depends. I would strongly suggest you avoid blanket implementation of all these improvements, as they often clash, and it will not typically lead to an optimal solution. The correct thing to do is to write your code with these options in mind, implementing these improvements as necessary after testing or during development when it is obvious.
Using for
loops as an example, when doing day-to-day coding, I tend to use standard SOQL for
loops, as they are more readable, and it is a nice...