简体   繁体   中英

Separate Service and Business layers in ASP MVC app architecture?

last few days i'm reading alot about apps architecture as i prepare myself for new project. So far, i pretty much used architecture like:

Presentation layer (ASP MVC controllers) Business layer [using domain model] Repository

Those use depencency injection with composition root.

As i read last days, I've found quite a few resources that suggest having something like:

Presentation layer Service layer Business layer Repository

So, having Service layer in between Presentation and Business. The only thing i can see going in that one is automapper so Service layer would act as an intermediate to prepare input (model) for business layer. If that is the only benefit then i'm not sure i would go with whole new layer for it. I'd sacrifice thin controller story and put automapper into controller if that is the only benefit of Service layer.

So, the question is...is there some other benefits of having Service layer in front of Business one that i'm missing?

Any thoughts would be highly appreciated! thanks

Service Layer is a thin wrapper over your domain Model(Business). You can use any pattern like Facade for creating Service Layer since Service Layer will be responsible for composing business logic as per your requirements.There are lot many facets to this but if you are having simple CRUD application, this will suffice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM