When To Use Programmatic Over Declarative


Sometimes the lines between declarative & programmatic get a bit blurred, it might not always be clear which one to use in specific scenarios.

First of all, what is declarative or programmatic?

Declarative is Salesforce’s point & click features, so that encompasses features like Process Builder and Flow. It requires no proper understanding of programming & programming concepts yet provides the ability to powerful actions.

  • Out-of-the-box & ready to go,

  • Simple & easy to use,

  • Easily upgradeable & maintainable,

  • Doesn’t require a developer,

  • Strongly supported by Salesforce.

Programmatic, as the name suggests, is programming. This may be Apex, Visualforce, JS, and so on, and gives developers the ability to go beyond what declarative has to offer.

  • Provides more control & flexibility,

    • In both the logic, actions, and visual aspects,

  • Further expand on what declarative has to offer.

So when would you opt for a programmatic solution? When there’s complex logic involved that either cannot be done declaratively or would be much easier & more efficient to do in Apex. Or maybe you want to offer your users a custom UI that is triggered by a Quick Action.

Although there are no set rules for when to use one over the other, always try and use declarative over programmatic solutions; or combine the 2.

In summary, use declarative where you can. There will be times when declarative cannot achieve what you want, and these are the times you should consider using a programmatic option. Although Salesforce are constantly evolving their declarative options to handle more complex logic & perform more advanced actions, they’re still not even.

Cameron Ofoluwa

Cameron Ofoluwa

22 Year Old Salesforce Developer @ Pogust Goodhead & Founder of SFDXHours.

Leave a Reply

Your email address will not be published. Required fields are marked *