Summary
Through the Selector pattern covered in this chapter, you have learned about a powerful layer of encapsulation that is used for some critical logic in your application. This enforces the best practices surrounding security and provides a more consistent and reliable basis for code dealing with the SObject
data.
You also learned that Selectors can also assume the responsibility and concern for platform features such as Multi-Currency and Field Sets. Ultimately, allowing the caller—be that the Service, Domain, Apex controllers, or Batch Apex—to focus on their responsibilities and concerns leads to cleaner code that is easier to maintain and evolve.
With the introduction of the Selector factory, we discovered some common features provided by this layer in the form of the Application.Selector.selectById
and Application.Selector.newInstance
methods, opening up the potential for more dynamic scenarios, such as the compliance framework highlighted in the last...