The 10 commandments of Salesforce Development

SF Connect
2 min readFeb 16, 2024

Salesforce development best practices are essential for creating efficient, maintainable, and scalable applications on the Salesforce platform. Here are 10 commandments that encapsulate key best practices for Salesforce development:

  1. Thou Shalt Not Put SOQL Queries Inside Loops: Placing Salesforce Object Query Language (SOQL) queries inside loops can lead to hitting governor limits by executing too many queries in a single transaction. Always bulkify your code to handle multiple records efficiently.
  2. Thou Shalt Use Bulk API for Large Data Operations: When dealing with large sets of data, utilize the Salesforce Bulk API for inserts, updates, deletes, and queries. This ensures that your operations are performed efficiently and are less likely to hit governor limits.
  3. Thou Shalt Embrace Apex Governor Limits: Salesforce imposes governor limits to ensure that runaway code does not monopolize shared resources. Developers must understand and respect these limits, designing solutions that operate within these constraints.
  4. Thou Shalt Write Testable Code and Achieve High Test Coverage: Ensure your Apex classes and triggers have comprehensive test coverage (at least 75% is required, but aim for more) and write tests that verify the logic of your application under various conditions.
  5. Thou Shalt Use Declarative Features Before Code: Always explore and prioritize the use of Salesforce’s declarative (no-code) features like Process Builder, Workflow Rules, and Validation Rules before resorting to writing custom Apex code or triggers.
  6. Thou Shalt Keep Business Logic Out of Triggers: Maintain lean triggers and encapsulate business logic within Apex classes. This practice makes your code more modular, easier to test, and simplifies trigger management.
  7. Thou Shalt Not Hardcode IDs or URLs: Hardcoding record IDs, URLs, or other environmental specific values makes your code fragile and not deployable across different Salesforce environments. Use Custom Settings, Custom Metadata Types, or labels to store such values.
  8. Thou Shalt Use Asynchronous Apex for Long-Running Processes: For processes that are not required to execute immediately, use asynchronous Apex (e.g., Future methods, Queueable Apex, Batch Apex) to avoid holding up user operations and to manage resource consumption better.
  9. Thou Shalt Make Use of Salesforce’s Security Model: Ensure your code respects and enforces Salesforce’s sharing rules, field-level security, and CRUD permissions to safeguard data access and integrity.
  10. Thou Shalt Document Your Code Thoroughly: Maintain detailed comments within your code to explain the purpose of complex logic, assumptions made, and reasons for particular implementations. This documentation is invaluable for maintenance and future development efforts.

Adhering to these commandments can significantly improve the quality and sustainability of Salesforce development projects, ensuring that applications are robust, efficient, and scalable.

--

--

SF Connect
SF Connect

Written by SF Connect

Technical Architect @ SF Connect. Feel free to contact me for expert level Salesforce consulting, development, and staffing. https://sfconnect.com/contact/

No responses yet