Questions tagged [service-layer]

A Service Layer represents one application boundary and consists of a 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. In enterprise OOP it is often the glue between an application's Model/Data Layers and its Presentation Layers.

A Service Layer represents one application boundary and consists of a 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. In enterprise OOP it is often the glue between an application's Model/Data Layers and its Presentation Layers.

This excerpt was heavily borrowed from Martin Fowler's book - http://martinfowler.com/eaaCatalog/serviceLayer.html

395 questions
7
votes
3 answers

Application Service Layer - how to write API method interfaces

How do people design their service layer interfaces? I'm programming a large web application (in PHP) and we're using MVC, and programming thin controllers e.g. (pseudo code follows) public savePersonAction() { $input = filter($_GET); ...…
7
votes
2 answers

Am I using service layer correctly?

I have been reading up on DDD and I think I may be using services wrong or at least in a not so ideal way. My service classes tend to have quite a few instance variables containing repository references and they seem to do a lot of work (i.e have a…
chobo
  • 31,561
  • 38
  • 123
  • 191
7
votes
5 answers

How to decouple eloquent from the service layer?

I am attempting to create a clean cut service layer, whereby the service layer acts upon one or more repositories, and each repositories acts on its own eloquent model. For example, I may have: ForumService | +-- PostRepo extends PostInterface …
Chris
  • 54,599
  • 30
  • 149
  • 186
7
votes
1 answer

Should aggregate roots have dependencies?

In Eric Evan's book "Domain Driven Design" (which people often call 'the best example for DDD'), there are many examples of aggregate roots (mostly domain models or even entities) that fullfil a certain request. Let's take the following…
Acrotygma
  • 2,531
  • 3
  • 27
  • 54
7
votes
3 answers

ObservableCollection in the service layer of the WPF MVVM application

Examples of WPF MVVM apps I've seen on the Internet consider VM a layer which interacts with a service layer which either uses "old" events from an external library, or interacts with web using HTTP or whatever. But what if I build all M, V, VM,…
Athari
  • 33,702
  • 16
  • 105
  • 146
6
votes
3 answers

MVC - Controller to Service Layer Communication

In my ASP.net mvc app I am using a Service Layer and Repositories to keep my controllers thin. A typical details read only view looks like this: public ActionResult Details(int id) { var project = _projectService.GetById(id); return…
Dismissile
  • 32,564
  • 38
  • 174
  • 263
6
votes
0 answers

How do I inject access control into a service layer of mvc application?

I'm coding a zend framework application using the the standard mvc paradigm with an added service layer to take care of application/business logic. It seems quite popular to put your access control into your services, rather than your…
clarkstachio
  • 613
  • 4
  • 8
6
votes
3 answers

Strongly typed Linq filtering method

I am a bit tired of writing lines of service layer codes like these: Below codes just an example for readers. So they may have errors or typos, sorry about it :) //ViewModel public class EntityIndexFilterPartial { public int? Id { get; set; } …
Yusuf Uzun
  • 1,491
  • 1
  • 13
  • 32
6
votes
3 answers

DTO's and calls between services

Say I have two services in my service layer, ServiceA and ServiceB, each with an interface (IServiceA and IServiceB respectively). The UI layer only has reference to the service interfaces which return DTOs from their methods. The concrete service…
Brett Postin
  • 11,215
  • 10
  • 60
  • 95
6
votes
3 answers

.NET MVC Best practices as far as keeping the controller from being very unreadable

I have been developing my first large (for me) MVC project for a couple of months now and things are getting exceedingly difficult to navigate. I have been slacking off on refactoring and am seeking modern examples of 'best practices' as far as…
Ecnalyr
  • 5,792
  • 5
  • 43
  • 89
6
votes
1 answer

Data access and security in service layer (Doctrine & ZF)

We recently started using Doctrine 2.2, and parts of Zend Framework 2 in an effort to improve organization, reduce duplication, among other things. Today, I started throwing around ideas for implementing a service layer to act as a intermediary…
5
votes
2 answers

AutoMapper in Service Layer

I have an MVC project where I am using AutoMapper to map my Entity Framework Entities to View Models. The code that defines the mappings is in a boostrapper class that is called automatically when the application starts (App_Start, Global.asax) I am…
Dismissile
  • 32,564
  • 38
  • 174
  • 263
5
votes
2 answers

Getting all aggregate root entities child entities?

I am attempting to refactor my application from a repository per entity to a repository per aggregate root. A basic example would be I have an entity root of Cars. Cars have hire contracts. As far as I can see contracts don't exist without cars…
5
votes
1 answer

Help creating a flexible base 'find' method in a service class using the DRY principle

For years now I've been reimplementing the same code over and over (with evolution) without finding some method of cleanly, and efficiently, abstracting it out. The pattern is a base 'find[Type]s' method in my service layers which abstracts select…
5
votes
1 answer

ZF + Doctrine 2 : Heavy model classes or Lightweight model + Service layer?

I am integrating Zend Framework and Doctrine 2, and I am discovering the Service layer. Now I understand (am I wrong ?) that I have 2 architectures possible : A model, where classes contain domain logic, i.e. properties + getters/setters + complex…
Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261