Introducing the Service layer pattern
The following is Martin Fowler’s definition of the Service layer (http://martinfowler.com/eaaCatalog/serviceLayer.html):
“[The Service layer] 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 its execution contexts caller. This might be a Lightning Web Component 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...