Best Practices in Apex Code
This will not only improve the code quality but also make it easy to enhance in future.
- Bulkified code - Use collection like map or list
- Avoid DMLs inside loops
- Avoid query inside loops
- Donot hard code in the code- Use custom labels, custom settings etc
- Try to keep each method short so that code is easily understandable
- Always put a comment for a class and for each method
- Try to put Null checks where ever it us possible. Use Safe Navigation Operator.
- 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