Thursday, November 8, 2018

Best Practices for writing Apex Code in Salesforce.com

Best Practices for writing Apex Code

1) Bulkify your controller code.

2) Use static and transient keyword for variable if possible.

3) Avoid SOQL queries inside for loops.

4) Avoid DML statements inside for loops.

5) Bulkify your helper methods.

6) Use collections like list, set and map to store data.

7) Use streamline queries and efficient for loops to process large set of data.

8) Use limits in SOQL to avoid hitting governor limits.

9) Use @future appropriately to execute code in separate thread.

10) Use batch apex or queueable apex to manipulate large set of data in batches.

11) Avoid hard code IDs.

12) Use try and catch block to handle exception, and throw error messages.











No comments:

Post a Comment

Validation in flow input text field in sfdc: Maximum 255 characters limit

The input text field validate in sfdc flow behaves opposite of the generic sfdc validation rule.  Here the validation formula is evaluating ...