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 dramatically improve CPU time usage, but also increased 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 and implement these improvements as necessary after testing or during development when it is obvious.
Using the for
loops as an example, when coding day to day, I tend to use standard SOQL for
loops as they are more readable and it is a nice piece of syntactical...