Using trigger handler frameworks
Trigger handler frameworks are a well-established architectural pattern across the entire Salesforce ecosystem for good reason. For one, they provide a standardized way of separating out your code for a trigger in a way that makes maintaining and testing the code simpler.
At its core, a trigger handler framework should do three things:
- Provide a simple and repeatable way of creating and managing trigger code.
- Provide a repeatable and abstracted way of handling how to switch trigger contexts.
- Allow the handler code to be tested without the need to execute the trigger.
Many frameworks also provide additional logic handling and management, but for the most basic handlers, these three functions should be provided. In this section, we'll learn how to build a simple framework to meet these needs.
Note
In this section, we are going to draft a simple framework to meet these requirements. In practice, I recommend using a...