Salesforce Apex Trigger Best Practices
Bulkify your Code:-
- We should bulkify the apex code to make sure our code properly handles more than one record at a time.
Avoid DML statment or SOQL query inside any FOR loop:-
- When we use DML or SOQL query inside a FOR loop because database operations are invoked for each iteration and it leads on hitting governor limits.
- So the safer side is move database operations outside of for loop.
Apex Trigger Execution Flow pictorial representation :-