2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Service Layer
|
|
|
|
folder: service-layer
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/service-layer/
|
2015-08-20 21:40:07 +02:00
|
|
|
categories: Architectural
|
2015-12-28 15:52:44 +02:00
|
|
|
tags:
|
2019-12-13 21:09:28 +02:00
|
|
|
- Data access
|
2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Intent
|
|
|
|
Service Layer is an abstraction over domain logic. Typically
|
2015-08-13 23:54:40 +02:00
|
|
|
applications require multiple kinds of interfaces to the data they store and
|
|
|
|
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 Service Layer fulfills this role.
|
|
|
|
|
2019-12-07 20:01:13 +02:00
|
|
|
## Class diagram
|
2015-08-13 23:54:40 +02:00
|
|
|

|
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Applicability
|
|
|
|
Use the Service Layer pattern when
|
2015-08-13 23:54:40 +02:00
|
|
|
|
2019-12-13 21:09:28 +02:00
|
|
|
* You want to encapsulate domain logic under API
|
|
|
|
* You need to implement multiple interfaces with common logic and data
|
2015-09-03 18:17:07 +05:30
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Credits
|
2015-09-03 18:17:07 +05:30
|
|
|
|
|
|
|
* [Martin Fowler - Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html)
|
2015-09-24 12:23:02 +05:30
|
|
|
* [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
|