Apex Best Practices:
- Don’t use hardcoded IDs
- No DML or SOQL inside loops
- Exception handling
- Code should be bulkified
Trigger Best Practices:
- There should be one trigger per object
- Should be bulkified and able to process at least 200 records
- Use collections to retrieve records in single query
- Proper naming convention
- Follows apex best practices also
Visualforce Page Best Practices:
- Don’t use hardcoded picklist values
- JavaScript and CSS should be stored in static resource
- Use transient variable, if variable is not used in server call
- View state size must be under 135KB
- Have you notice, In VF pages view state is generated only when you use form tag otherwise it will not generate? Try and comment below.
Test Class Best Practices:
- Should have all the data needed for the method
- Don’t use SeeAllData=true
- Proper assert statements
- Should include both positive and negative test cases
- Use Test.startTest() and Test.stopTest properly
- Use System.runAs() to execute code as a specific user.
Lightning Component Best Practices:
- Don’t fetch same data in different components
- Use LDS wherever is possible
- Data filtering or caching logic should be on the client side
- Limit the use of Application events
- Use base lightning components
- Use SLDS
- Proper use of bound and unbound expressions.
For detailed information follow these links:
https://xperiencepartage.wordpress.com/2018/12/24/lightning-data-service
https://xperiencepartage.wordpress.com/2019/02/07/lightning-component-best-practices
Leave a comment