Introducing the Service layer pattern
The following is Martin Fowler's definition of the Service layer (http://martinfowler.com/eaaCatalog/serviceLayer.html):
"Defines an application's boundary with a layer of services that establishes a set of available operations and coordinates the application's response in each operation."
The use of the word "boundary" in Martin's definition is interesting, as this literally represents the point of separation or boundary between the concerns of the application's business logic in the Service layer and execution context or caller, be that a Visualforce Controller class or a Batch Apex class, as illustrated in the UML diagrams shown in the previous chapter.
The following illustration shows just some of the types of callers that an Apex Service layer is designed to support. By following the design guidelines given in the next diagram, you can ensure that your Service layer code can be called from any one of these features and others in the future:
This book...