Apex trigger framework interview questions
Once you say "I use a trigger framework", the follow-ups start. Here is how to explain the handler pattern, recursion control and bypass logic without sounding rehearsed.
On this page (6 sections)
Interview questionsCommon MistakesRelated Trigger Framework Interview QuestionsFrequently Asked Questions about Trigger Framework InterviewsRelated CertificationsRelated ResourcesNew to this topic? Learn Apex step by step before you practise.
Almost every senior Apex interview asks about Trigger Frameworks, not because the pattern is complex, but because it tells the panel whether you've built scalable orgs or just patched things together. Here's how to talk about it like an architect.
01What is a Trigger Framework and why do we need one?
What is a Trigger Framework and why do we need one?
A Trigger Framework is a design pattern that puts trigger logic into structured handler classes instead of a giant trigger body. Benefits: one trigger per object, separation of concerns, easy unit testing, recursion control, and the ability to bypass triggers in tests or migrations.
02What does a basic framework look like?
What does a basic framework look like?
Trigger on Account → calls AccountTriggerHandler.run() → run() dispatches to beforeInsert(), afterUpdate() etc. methods based on Trigger.operationType. Each handler method is small and testable. Most teams either build their own or use a popular open-source one (e.g. Kevin O'Hara's framework).
03Why one trigger per object?
Why one trigger per object?
Order of execution between multiple triggers on the same object is undefined. With one trigger and a handler dispatching in code, you control execution order explicitly. This avoids painful 'works on dev, broken in prod' bugs.
04How do you prevent recursion in a framework?
How do you prevent recursion in a framework?
Use a static Set<Id> of already-processed record IDs in the handler. On each run, skip records already in the set. Add to the set after processing. Smarter than a boolean flag because it lets new records process while preventing reprocessing of the same record.
05How do you bypass a trigger for a data load?
How do you bypass a trigger for a data load?
Hierarchy custom setting like 'Trigger_Bypass__c' with a checkbox per object. Handler checks the setting at the top of run() and exits if true. Admins toggle it before a one-off data load.
06How do you unit test a trigger handler?
How do you unit test a trigger handler?
Test the handler class methods directly, not just through DML. Insert test data, call AccountTriggerHandler.beforeUpdate(newList, oldMap) directly, then assert. Faster, deterministic, and easier to debug.
07What is the difference between procedural and OOP trigger frameworks?
What is the difference between procedural and OOP trigger frameworks?
Procedural: a handler with static methods, dispatched by a giant if/else on operation type. OOP: handler extends an abstract TriggerHandler base class that defines virtual methods like beforeInsert, afterUpdate. OOP is cleaner for large orgs with many objects.
08How do you log trigger errors centrally?
How do you log trigger errors centrally?
Wrap each handler method in try/catch, log to a custom Apex_Error_Log__c with class, method, record IDs, and stack trace. Re-throw so the user still sees the failure. Centralised logging is what auditors and architects look for.
09How do you handle order between handlers when multiple flows + triggers exist?
How do you handle order between handlers when multiple flows + triggers exist?
Document the order of execution in a design doc. Use the standard order: validations → before triggers → DML → after triggers → assignment rules → workflows → flows. If both a flow and a trigger update the same field, move one to before-save flow or remove the duplication.
10What does a senior engineer evaluate in a Trigger Framework?
What does a senior engineer evaluate in a Trigger Framework?
Bulkification, recursion control, bypass strategy, testability, error handling, separation of business logic from trigger plumbing, and consistency across objects. If your framework gives all of that, it's senior-grade.
Common Mistakes
Multiple triggers per object. Always one trigger, one handler.
Boolean recursion flag. Use a Set of IDs for fine-grained control.
No bypass mechanism. Data loads will get blocked by triggers.
Logic in the trigger body. Trigger should only call handler.run().
Frequently Asked Questions about Trigger Framework Interviews
Is a framework necessary for small orgs?
Even small orgs benefit because they grow. Starting with a framework is cheaper than refactoring later.
Can I use the same framework across orgs?
Yes. Package the base TriggerHandler class as an unlocked package or include in a shared utility library.
Do flows replace the need for trigger frameworks?
No, flows have their own coordination needs. Frameworks are for Apex.
How do I disable a single handler in production?
Use a custom metadata 'Trigger_Switches__mdt' with a record per handler: admins flip a checkbox.
Should I write my own or use an open-source framework?
For small orgs, write your own (200 lines). For complex orgs, an established framework gives you tested patterns.
Related Certifications
PD1, PD2 and Application Architect cover triggers in depth. See certification guides.