Tuesday, October 12, 2021

Best Practices in Apex

Best Practices in Apex Code


This will not only improve the code quality but also make it easy to enhance in future.

  1. Bulkified code - Use collection like map or list
  2. Avoid DMLs inside loops
  3. Avoid query inside loops
  4. Donot hard code in the code- Use custom labels, custom settings etc
  5. Try to keep each method short so that code is easily understandable
  6. Always put a comment for a class and for each  method
  7. Try to put Null checks where ever it us possible. Use Safe Navigation Operator.
  8. Use try catch block - This will help to capture the scenarios which gets missed in try block.

Please share the blog and leave a comment about your thoughts.
Click here for more blogs.

No comments:

Post a Comment