Summary
In this chapter, we took a deep dive into how Apex triggers function and how to improve our triggers through the use of trigger handlers.
We started by discussing the Salesforce save order of execution, how it operates, and the side effects that it can have when it is not properly accounted for when it comes to designing and developing solutions. As we discussed, not correctly accounting for the way in which it fires different actions can lead to recursion and overuse of resources, including unintended side effects and governor limit breaches in the most extreme scenarios.
With this knowledge, we reviewed how we should correctly architect our triggers for scalability and built out a basic trigger handler pattern to enable us to manage and maintain our code. This handler met our three criteria and allowed us to separate the execution of the code for our triggers from the actual trigger itself, thus making it easier to maintain and test.
Finally, we looked at how we...