Book Image Enterprise Architecture

By : Andrew Fawcett
Book Image Enterprise Architecture

By: Andrew Fawcett

Overview of this book

Table of Contents (20 chapters) Enterprise Architecture
About the Author
About the Reviewers

Domain class template

The Domain class implementation in this chapter utilizes the Apex Enterprise Patterns library, which is open source and is included in the sample code of this chapter. In this library, the Apex base class, fflib_SObjectDomain, is provided to help implement the Domain layer pattern.

A basic template for a Domain class utilizing this base class is shown in the following code snippet:

public class Races extends fflib_SObjectDomain
  public Races(List<Race__c> races) 

  public class Constructor
    implements fflib_SObjectDomain.IConstructable
    public fflib_SObjectDomain construct(List<SObject> sObjectList){
      return new Races(sObjectList);

The first thing to note is that the constructor for this class takes a list of Race__c records, as per the guidelines described previously. The code implemented in a domain class is written with bulkification in mind. The base class constructor initializes...