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 alterative 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); } }
We can then reference a custom setting (the Application setting has been included in the source code for this chapter) to determine whether Developer X has provided an implementation of this interface to call instead of the standard calculation code. The following code uses the Type.forName
methods to construct at runtime the Apex type and create an instance of the type that can be cast to the interface.
Notice how the code supports Developer X providing a class name that...