service-layer

Separating the service layer from the validation layer

丶灬走出姿态 提交于 2019-11-27 09:02:05
问题 I currently have a service layer based on the article Validating with a service layer from the ASP.NET site. According to this answer, this is a bad approach because the service logic is mixed with the validation logic which violates the single responsibility principle. I really like the alternative that is supplied but during re-factoring of my code I have come across a problem that I am unable to solve. Consider the following service interface: interface IPurchaseOrderService { void

Should the repository layer return data-transfer-objects (DTO)?

半城伤御伤魂 提交于 2019-11-27 06:55:00
I have a repository layer that is responsible for my data-access, which is called by a service layer. The service layer returns DTOs which are serialized and sent over the wire. More often than not, services do little more than access a repository and return whatever the repository returns. But for that to work, the repository has to return an instance of that DTO. Otherwise, you would first have to map the data layer object that the repository returns to a DTO in the service layer and return that. That just seems wasteful. On top of that, if creation of the DTOs happens in the service layer,

Why use service layer?

允我心安 提交于 2019-11-27 06:37:55
I looked at the example on http://solitarygeek.com/java/developing-a-simple-java-application-with-spring/comment-page-1#comment-1639 I'm trying to figure out why the service layer is needed in the first place in the example he provides. If you took it out, then in your client, you could just do: UserDao userDao = new UserDaoImpl(); Iterator users = userDao.getUsers(); while (…) { … } It seems like the service layer is simply a wrapper around the DAO. Can someone give me a case where things could get messy if the service layer were removed? I just don’t see the point in having the service layer

Fat model / thin controller vs. Service layer [closed]

[亡魂溺海] 提交于 2019-11-27 05:47:46
I have been developing enterprise applications for many years using .Net My apps usually have a domain model containing entities mapping to SQL DB tables. I use a Repository pattern, Dependency injection and a service layer. Recently we started working on MVC 3 projects and we had a debate where to put which logic. I came accross thin Controller / FAT Model architecture and was wondering how the service layer would fit in Option 1 - Model talks to services Controller is thin, calls methods on the models. The models "know" how to load themselfs from the DB and talk to repositories or services.

The Purpose of a Service Layer and ASP.NET MVC 2

China☆狼群 提交于 2019-11-27 04:14:11
问题 In an effort to understand MVC 2 and attempt to get my company to adopt it as a viable platform for future development, I have been doing a lot of reading lately. Having worked with ASP.NET pretty exclusively for the past few years, I had some catching up to do. Currently, I understand the repository pattern, models, controllers, data annotations, etc. But there is one thing that is keeping me from completely understanding enough to start work on a reference application. The first is the

Should a service layer return view models for an MVC application?

有些话、适合烂在心里 提交于 2019-11-26 19:05:27
问题 Say you have an ASP.NET MVC project and are using a service layer, such as in this contact manager tutorial on the asp.net site: http://www.asp.net/mvc/tutorials/iteration-4-make-the-application-loosely-coupled-cs If you have viewmodels for your views, is the service layer the appropriate place to provide each viewmodel? For instance, in the service layer code sample there is a method public IEnumerable<Contact> ListContacts() { return _repository.ListContacts(); } If instead you wanted a

Should ServiceStack be the service layer in an MVC application or should it call the service layer?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 18:28:11
I'm creating an MVC website and also intend to create a web API for use both within the website and potentially by third parties. From the MVC controllers I'll be calling into a service layer which will contain business logic, act on domain models, perform validation, make infrastructure external service calls etc. The service layer in turn will call into repositories for any database interactions. Now, I like the look of ServiceStack and intend on using it for the Web API - it seems more mature than the ASP.NET MVC 4 Web API . My question is, should I have the ServiceStack API call into my

Handling service layer exception in Java EE frontend method

随声附和 提交于 2019-11-26 17:57:22
I maintain a web application that have a page with the JSF tag <f:event . I have rewrote a method in a service class for it to throw a business exception. However, when the business exception is thrown, it isn't caught in managed bean and the exception is showed on the page. Seems that my code try/catch doesn't work. In XHTML: <f:event listener="#{resourceBean.init(enrollment)}" type="preRenderView" /> Listener method in Managed Bean: private boolean canCreateResource; public void init(Enrollment enrollment) { (...) try { canCreateResource = resourceService.canCreateResource(enrollment); }

Should the repository layer return data-transfer-objects (DTO)?

為{幸葍}努か 提交于 2019-11-26 12:56:31
问题 I have a repository layer that is responsible for my data-access, which is called by a service layer. The service layer returns DTOs which are serialized and sent over the wire. More often than not, services do little more than access a repository and return whatever the repository returns. But for that to work, the repository has to return an instance of that DTO. Otherwise, you would first have to map the data layer object that the repository returns to a DTO in the service layer and return

Why use service layer?

╄→гoц情女王★ 提交于 2019-11-26 12:07:16
问题 I looked at the example on http://solitarygeek.com/java/developing-a-simple-java-application-with-spring/comment-page-1#comment-1639 I\'m trying to figure out why the service layer is needed in the first place in the example he provides. If you took it out, then in your client, you could just do: UserDao userDao = new UserDaoImpl(); Iterator users = userDao.getUsers(); while (…) { … } It seems like the service layer is simply a wrapper around the DAO. Can someone give me a case where things