Trigger Handler - cdelfattore/apex-enterprise-patterns GitHub Wiki
Introduction
Apex enterprise design patterns handles trigger logic differently than a basic apex trigger handler. A basic trigger handler framework that I have seen used is calling static methods in a trigger handler class, using trigger context variables to specify when certain methods should run and static variables to prevent recursion. Apex enterprise design patterns will have developers extend the fflib_SObjectDomain virtual class and override methods that represent the different trigger events.
Virtual Classes
The virtual class to extend for a trigger handler is the fflib_SObjectDomain class. This virtual class can also be use to create a domain class, but shouldn't. You will see older versions of fflib code use the fflib_SObjectDomain for both a domain and trigger handler classes. The latest versions of fflib will have the trigger handler code be broken out seperatly from the domain functions. Reminder, the virtual class that should be extended for a domain class is fflib_SObjects.
Example
The actual trigger class contains one line that references the trigger handler class.
The trigger handler code sample can be found below.
A full list of the properties and overridable methods for the fflib_SObjectDomain can be found here