Extending the application logic with Apex interfaces
An Apex Interface can be used to describe a point in your application logic where custom code written by Developer X can be called. For example, in order to provide an alternative means to calculate championship points driven by Developer X, we might expose a global interface describing an application callout that looks like this:
global class ContestantService {global interface IAwardChampionshipPoints { void calculate(List<Contestant__c> contestants); } }
By querying Custom Metadata records from the Callouts custom metadata type, which has been included in the source code for this chapter, code in the application can determine whether Developer X has provided an implementation of this interface to call instead of the standard calculation code.
Using Custom Metadata is an excellent use case for this sort of requirement, since you can declare the callouts your package supports by packaging records. Then, by making certain fields...