Book Image

Force.com Enterprise Architecture

By : Andrew Fawcett
Book Image

Force.com Enterprise Architecture

By: Andrew Fawcett

Overview of this book

Table of Contents (20 chapters)
Force.com Enterprise Architecture
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

The Selector class template


A Selector class such as the Domain class utilizes inheritance to gain some standard functionality, in this case, the base class delivered through the FinancialForce.com Enterprise Apex Patterns library, fflib_SObjectSelector.

A basic example is as follows:

public class RacesSelector extends fflib_SObjectSelector
{
   public List<Schema.SObjectField> getSObjectFieldList()
   {
     return new List<Schema.SObjectField> {
        Race__c.Id,
        Race__c.Name,
        Race__c.Status__c,
        Race__c.Season__c,
        Race__c.FastestLapBy__c,
        Race__c.PollPositionLapTime__c,
        Race__c.TotalDNFs__c };
   }

   public Schema.SObjectType getSObjectType()
   {
      return Race__c.sObjectType;
   }
}

Tip

The base class uses Dynamic SOQL to implement the features described in this chapter. One potential disadvantage this can bring is that references to the fields are made without the Apex compiler knowing about them, and as such, when you...