📖 Read · 20 XP
Clicks before code: when not to write Apex
Clicks before code
Salesforce has a famous motto: clicks, not code. As a developer, your first job is often working out that you don't need code at all.
The declarative toolbox
| Need | Declarative tool |
|---|---|
| Calculated value | Formula field |
| Sum or count of child records | Roll-up summary field |
| Block bad data | Validation rule |
| Automate on save, send emails, guide users | Flow |
| Control access | Permission sets, sharing rules |
These are metadata, not code. They need no tests, and admins can maintain them.
When code wins
Reach for Apex when you need:
- Complex logic that would turn into an unreadable Flow
- Large data volumes and fine control over limits
- Integrations: callouts, custom APIs, complex JSON
- Reusable, unit-tested business logic
Reach for LWC when the standard UI and screen flows can't deliver the experience you need.
The professional answer
Good Salesforce developers are fluent in both and choose on purpose. Plenty of PD1 exam questions are scenarios that ask exactly this: "What's the best way to…?" Often the answer is the declarative one.
🦝 Quill's rule: if an admin can maintain it, let an admin maintain it.