Keep one trigger per object, containing no logic, which delegates to a handler class with a method for each context such as before insert or after update. That gives a predictable order, logic you can unit test and reuse, one place for recursion control, and a way to bypass automation for data loads. Business logic then lives in service classes the handler calls, not in the trigger itself.
Why interviewers ask this
Multiple triggers on the same object run in no guaranteed order, and logic written directly in triggers becomes untestable and tangled quickly. The interviewer wants to see that you understand why the pattern exists, not just that you have copied one. They listen for one trigger per object, context methods, recursion control, bypass switches and separated business logic, because those are what keep a mature org maintainable.
How to structure your answer
- Explain the problems with logic directly in triggers.
- Describe one trigger per object delegating to a handler.
- Cover recursion control and bypass switches.
- Explain where business logic lives and how you test it.
Example answer
Without a framework you end up with several triggers on Account written by different people, and Salesforce does not guarantee the order they run in, so behaviour depends on luck. Logic written directly inside triggers is also hard to test and impossible to reuse. So my rule is one trigger per object, and the trigger has a single line that hands off to a handler. The handler has a method per context, before insert, after update and so on, and decides what to call. The business logic lives in service classes, like an account ownership service, which take collections and can be called from the handler, a batch job or an API. The framework also gives me two switches. One is recursion control, usually a static set of record ids already processed in this transaction, so an update that causes another update does not run the logic twice. The other is a bypass, driven by custom metadata or a custom permission, so a large data migration can switch off chosen automation without a deployment.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How would you stop a trigger running twice in the same transaction?
- How would you let admins switch off a trigger without a deployment?
- Where would you put logic that several objects need?
Related salesforce developer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions