Salesforce Platform Developer I (legacy) — Question 65
A developer identifies the following triggers on the Expense__c object: deteleExpense, applyDefaultsToExpense, validateExpenseUpdate;
The triggers process before delete, before insert, and before update events respectively.
Which two techniques should the developer implement to ensure trigger best practices are followed? (Choose two.)
Answer options
- A. Unify the before insert and before update triggers and use Process Builder for the delete action.
- B. Create helper classes to execute the appropriate logic when a record is saved.
- C. Maintain all three triggers on the Expense__c object, but move the Apex logic out of the trigger definition.
- D. Unify all three triggers in a single trigger on the Expense__c object that includes all events.
Correct answer: B, D
Explanation
Option B is correct because creating helper classes allows for cleaner, more maintainable code and separation of logic from the trigger itself. Option D is also correct as unifying triggers into one can reduce the risk of recursion and improve performance. Options A and C do not align with best practices as they either complicate the process or fail to fully separate logic from the triggers.