Summary
As we have seen in this chapter, future methods are a versatile and easy-to-work-with asynchronous processing option within Apex. They allow us to define discrete bundles of code that can be used for making long-running callouts or to avoid mixed DML errors when working with setup objects.
We have also seen some different methods of interacting with future methods to persist state and errors between transaction contexts, and finally saw how our future methods can be tested.
The reason we focus on future methods first in this section is that they are the simplest to invoke (just a static
method call) and therefore are easier to test. They also have limited out-of-the-box support for state transmission, which has to be mangled through the use of an object that persists across the transaction context.
In the next chapter, we are going to look into batch Apex, where state persistence and use cases differ from what we have seen.