# Declarative or programmatic: choosing the right tool

*Platform Developer Study Guide · Developer Fundamentals · Last updated October 15, 2026 · https://www.certifyforce.com/study-guide/platform-developer/developer-fundamentals/declarative-versus-programmatic*

When a formula field, roll-up summary, validation rule or Flow meets a requirement and when only Apex will do, with the formula and roll-up limits and the shared governor limits that decide the choice.

- Certification: Salesforce Platform Developer
- Exam section: Developer Fundamentals
- Study guide: https://www.certifyforce.com/study-guide/platform-developer

**Official exam objective:**

> Given a scenario, identify common use cases and best practices for declarative versus programmatic customizations, including governor limits, formula fields, and roll-up summaries.

## What the exam expects

- Given a requirement, choose a formula field, roll-up summary field, validation rule, Flow or Apex, and justify rejecting the others.
- Know what formula fields cannot do (child records, snapshots, long text) and their size limits.
- Know where roll-up summaries work, which functions they offer, and how to stage them across levels.
- Recognize requirements that exceed per-transaction governor limits and need Batch Apex or bulkified code.
- Key terms: **declarative** (configured in Setup, no code); **programmatic** (Apex or other code); **formula field** (read-only value calculated from the record and its parents); **roll-up summary field** (aggregate of detail records on the master); **governor limit** (a per-transaction resource cap shared by all automation in that transaction).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Formula length | 3,900 characters; 15,000 bytes saved or compiled | [Formula Field Limits and Restrictions](https://help.salesforce.com/s/articleView?id=platform.formula_field_limits.htm&type=5) |
| Fields formulas can't use | Long text area, encrypted, Description | [Formula Field Limits and Restrictions](https://help.salesforce.com/s/articleView?id=platform.formula_field_limits.htm&type=5) |
| Cross-object reach | Parents via lookup or master-detail, up to 10 relationships away | [What Is a Cross-Object Formula?](https://help.salesforce.com/s/articleView?id=platform.customize_cross_object.htm&type=5) |
| Roll-up types | COUNT, SUM, MIN, MAX | [Roll-Up Summary Field](https://help.salesforce.com/s/articleView?id=platform.fields_about_roll_up_summary_fields.htm&type=5) |
| Standard roll-up pairs | Account from opportunities; Opportunity from opportunity products; Campaign from campaign members | [Roll-Up Summary Field](https://help.salesforce.com/s/articleView?id=platform.fields_about_roll_up_summary_fields.htm&type=5) |
| Master-detail to lookup | Allowed only when no roll-up summary fields exist on the master | [Considerations for Object Relationships](https://help.salesforce.com/s/articleView?id=platform.relationships_considerations.htm&type=5) |
| Flow limits | Per-transaction Apex limits govern flows; 100 SOQL, 150 DML | [Per-Transaction Flow Limits](https://help.salesforce.com/s/articleView?id=platform.flow_considerations_limit_transaction.htm&type=5) |
| Batch Apex scope | QueryLocator returns up to 50 million records; each batch is its own transaction | [Use Batch Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm) |
| Production Apex | Unit tests must cover at least 75 percent of the code | [Platform Multitenant Architecture](https://developer.salesforce.com/wiki/multi_tenant_architecture) |
| Bulk DML | A list insert counts as one DML statement | [Apex DML](https://trailhead.salesforce.com/content/learn/modules/apex_database/apex_database_dml) |

## Check yourself

- Why can't a formula field record the price at the moment an order is submitted?
- When can a roll-up summary aggregate a formula field?
- Why doesn't moving trigger logic into a record-triggered flow avoid a SOQL limit error?
- What must you do before converting a master-detail relationship to a lookup?
- Which Apex collection guarantees each Account Id appears once?

## Sources

- [Record-Triggered Automation decision guide](https://architect.salesforce.com/docs/architect/decision-guides/guide/record-triggered)
- [Formula Field Limits and Restrictions](https://help.salesforce.com/s/articleView?id=platform.formula_field_limits.htm&type=5)
- [Build a Formula Field](https://help.salesforce.com/s/articleView?id=platform.customize_formulas.htm&type=5)
- [What Is a Cross-Object Formula?](https://help.salesforce.com/s/articleView?id=platform.customize_cross_object.htm&type=5)
- [Global Variables](https://help.salesforce.com/s/articleView?id=platform.dev_understanding_global_variables.htm&type=5)
- [Enhance Data Display with Formula Fields](https://trailhead.salesforce.com/content/learn/modules/point_click_business_logic/formula_fields)
- [Roll-Up Summary Field](https://help.salesforce.com/s/articleView?id=platform.fields_about_roll_up_summary_fields.htm&type=5)
- [Considerations for Object Relationships](https://help.salesforce.com/s/articleView?id=platform.relationships_considerations.htm&type=5)
- [Execution Governors and Limits](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)
- [Per-Transaction Flow Limits](https://help.salesforce.com/s/articleView?id=platform.flow_considerations_limit_transaction.htm&type=5)
- [Use Batch Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm)
- [Platform Multitenant Architecture](https://developer.salesforce.com/wiki/multi_tenant_architecture)
- [What is Apex?](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_intro_what_is_apex.htm)
- [Variables](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_variables.htm)
- [Expression Operators](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_expressions_operators_understanding.htm)
- [Rules of Conversion](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_rules_of_conversion.htm)
- [Sets](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_collections_sets.htm)
- [Improve Data Operations with Apex DML](https://trailhead.salesforce.com/content/learn/modules/apex_database/apex_database_dml)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 31 linked practice questions, and unlimited timed mock exams are included with the Platform Developer pack (USD $19): https://www.certifyforce.com/practice-exams
