Implementing custom Domain logic
A Domain class should not restrict itself to containing logic purely related to Apex Triggers. In the following example, the code introduced in the previous chapter to calculate championship points has been refactored into the Contestants
Domain class. This is a more appropriate place for it, as it directly applies to the Contestant record data and can be readily shared between other Domain and Service layer code (which we will look at later in this chapter):
public void awardChampionshipPoints(fflib_ISObjectUnitOfWorkuow) {
// Apply championship points to given contestants
Map<Integer, ChampionshipPoint__mdt> pointsByTrackPosition =
new ChampionshipPointsSelector().selectAllByTrackPosition();
for(Contestant__c contestant : (List<Contestant__c>) Records) {
// Determine points to award for the given position
ChampionshipPoint__mdt pointsForPosition =
pointsByTrackPosition.get(
...