Service Layer – Patterns of Enterprise Application Architecture

I love reading the book Patterns of Enterprise Application Architecture, by Martin Fowler & co. The following comes from it, page 133, on the topic of Service Layer.

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.
Enterprise applications typically require different kinds of interfaces to the data they store and the logic they implement: data loaders, user interfaces, integration gateways, and others. Despite their different purposes, these interfaces often need common interactions with the application to access and manipulate its data and invoke its business logic. The interactions may be complex, involving transactions across multiple resources and the coordination of several responses to an action. Encoding the logic of interactions separately in each interface causes a lot of duplication.


Service Layer defines an application’s boundary and its set of available operations from the perspective of interfacing client layers. It encapsulates the application’s business logic, controlling transactions and coordinating responses in the implementation of its operations.


The two basic implementation variations are the domain facade approach and the operation script approach.
In the domain facade approach, a Service Layer is implemented as a set of thin facades over a Domain Model. The classes implementing the facades don’t implement any business logic. Rather, the Domain Model implements all of the business logic.
In the operation script approach a Service Layer is implemented as a set of thicker classes that directly implement application logic but delegate to encapsulated domain object classes for domain logic. The operations available to clients of a Service Layer are implemented as scripts, organized several to a class defining a subject are of relatic logic. Each such class form an application “service”, and it’s common for service types names to end with “Service”.


Read the book and learn more on the topic.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s