0

With the introduction of queueable apex, is there a reason why we should opt for a future method instead?

Since we have many advantages in queueable like being able to pass sobjects or complex data types, chaining and monitoring, why should one choose future?

1

Future methods came first, while Queueable was an iterative evolution of future methods. The annotation is still required for backwards compatibility, but you should generally choose Queueable over future. You can still choose to use future methods if you don't care about monitoring, chaining, passing complex objects, etc. They offer no benefits except less complexity in terms of syntax (you don't need to construct an object and call a system method), but this is so trivially small a difference that I wouldn't consider it a benefit worth using.

| improve this answer | |
0

There is a good comparison in Salesforce's documentation, search these for "queueable" and "future"

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_async_overview.htm?search_text=future https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.