Apex Best Practices ChecklistHere is a great article on 15 commandments to Apex best practices, which I think every developer should create as a checklist when writing codes. Do read this as this can transform you from being just a developer to a good developer.


and here is a quick recap of what’s mentioned in the article

  1. Keep the code simple
  2. Don’t put queries in loops
  3. Utilize Map for queries
  4. Use relationships to reduce queries
  5. Don’t put DML in loops
  6. Create only one trigger per object
  7. Keep logic outside of trigger
  8. Prefer clicks over code where ever possible
  9. Aim for 100% code coverage
  10. Write meaningful tests with asserts
  11. Write unit tests before developing (i.e test driven development)
  12. Test all conditions
  13. Don’t use dummy code coverage
  14. Never test with existing data
  15. Don’t introduce extra logic for tests