In ApexHours we did one session on Apex Trigger Framework in Salesforce with ADAM OLSHANSKY. In that session we talk about what is a benefit of using a trigger framework, How many trigger framework are available, which one is lightweight apex trigger framework and Comparison of different approaches.
In that session we talk about all below Trigger Framework
1) Trigger Handler Pattern
2) Trigger Framework using a Virtual Class
3) Trigger Framework using an Interface
4) An architecture framework to handle triggers
Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
Please check our YouTube Recording to learn more about all Trigger Framework and Code.
https://www.youtube.com/watch?v=U5ZOA9EY3Kg&t=7s
Thank
In that session we talk about all below Trigger Framework
1) Trigger Handler Pattern
2) Trigger Framework using a Virtual Class
3) Trigger Framework using an Interface
4) An architecture framework to handle triggers
Why Trigger Framework ?
A framework may, however, greatly simplify your development efforts when your code base gets large. In a nutshell, your framework should have the following goals:-- Generic code that can be extended for any object
- Ensures triggers are consistently handled and only required code is needed
- Allows for simple Triggers and Handlers
- Handles routing for you
- Enforces consistent trigger behavior
- Easily allows for trigger bypasses
Trigger Handler Pattern
Please check this post to learn about Handler pattern and code. Lets talk about what is the advantage of Trigger Handler Patter.- Apex Class that handles trigger logic
- Allows code to be called from other code or tests
- Uses specific Trigger contexts and Trigger variables for routing
- Keep Triggers Simple
- Allow for greater flexibility
- Make code reusable
- Unit tests are much easier
Please check this recording for code walk-through. What is missing in Handler pattern ?
- Still duplicated code in every trigger
- How can we simplify things?
- How can we make our process repeatable?
Trigger Framework using a Virtual Class
Please check this post to learn more about Virtual Class Trigger Framework.Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
- 1 line trigger
- Only need to add handler methods that we want to use
- All routing is handled for us
Trigger Framework using an Interface
Please check this post to learn about this framework.Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
- 1 line trigger
- All routing is handled for us
- All handlers are consistent and will have the same methods
- Multiple ways to deactivate a trigger
An architecture framework to handle triggers
Please check this post to learn about this framework.Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
- 1 line trigger
- All routing is handled for us
- Establish all methods while letting us pick and choose which ones we want
- Individual event handler methods
Please check our YouTube Recording to learn more about all Trigger Framework and Code.
https://www.youtube.com/watch?v=U5ZOA9EY3Kg&t=7s
Here is link for all frameworks:-
- Trigger Frameworks and Apex Trigger Best Practices by Kevin O’Hara
- Trigger Pattern for Tidy, Streamlined, Bulkified Triggers by Tony Scott
- Hari Krishnan’s architecture framework
- Lightweight Apex Trigger Framework
Thank