I’ve seen a couple versions of rules developers feel are core to good Apex code. I’d like to throw these into the ring as concepts that have been helpful to me, and that I deviate from at my own peril:
- Write your tests FIRST
- NO hard coded values
- Use a test data factory
- Test for predictability, not coverage
- If it doesn’t assert, it’s not a test
- Use a custom error class
- Don’t repeat yourself
- JS > VF
- Don’t repeat yourself
- Standard is better than custom (use everything you pay for)
For a different perspective, here’s a DreamForce session that I absolutely agree with.