Introducing the Selector layer pattern
The following is Martin Fowler’s definition of the Data Mapper layer on 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 Salesforce 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 mirrors 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...