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

Introducing the Selector layer pattern


The following is Martin Fowler's definition of the Data Mapper layer from which the Selector layer pattern is based (http://martinfowler.com/eaaCatalog/dataMapper.html):

"A layer of Mappers (473) that moves data between objects and a database while keeping them independent of each other and the Mapper itself."

In Martin's definition, he is referring to objects as those resulting from the instantiation of classes within an OO language such as Java or Apex. Of course, in the Force.com world, this has a slightly ambiguous meaning, but is more commonly thought of as the Standard or Custom Object holding the record data.

One of the great features of the Apex language is that it automatically injects object types in the language that mirror the definition of the Custom Objects you define. These so-called SObjects create a type-safe bond between the code and the database schema, though you can also leverage Dynamic Apex and Dynamic SOQL to change these references...