Advantages and Drawbacks of @future Annotation in Apex

Advantages and Drawbacks of @future. There were some bottlenecks that @future was solving and soon it also started showing its age (drawbacks :p).

It was a relief when Salesforce had come up with @future annotation.

There were some bottlenecks that @future was solving and soon it also started showing its age (drawbacks :p). I will save that for another day, maybe.

The bottom rule is, we will convert Synchronous Apex to Asynchronous Apex using @future annotation which is one of the variants of Asynchronous Apex that Salesforce provides.

Advantages of @future annotation

  1. We can make a callout from Trigger using @future annotation
  2. When there are CPU time limit exceptions and SOQL 101 Exceptions we can use @future and push the business logic that's not of that priority to get executed in Asynchronous mode.
  3. We can increase the request timeout using @future annotation
  4. Scenarios like deleting a record on click of a checkbox and updating a record can only be configured using @future annotation.

Drawbacks with @future annotation

  1. We cannot invoke a future method within another @future method
  2. Future methods cannot be used in Batch Apex.
  3. @future method cannot return any data back.
  4. We cannot pass complex data types(List, Set, and Map), custom data types to a future method. We always have to send primitive data types.