문제

I was watching "storefront starter kit", its using repository pattern with service layer. In the video, he didnt really explain why he's using service layer. Seems like those are just extra.

what are pros and cons using service layer?

도움이 되었습니까?

해결책

For most asp.net mvc apps it is perfectly reasonable and preferable for your controllers to directly address the repository (via an interface). I would only add a service layer when you need to, for example when other apps are interfacing with your application. In my opinion you should avoid unnecessary abstraction layers.

다른 팁

Repository is your Data Layer ... it's responsibility is to fetch and save data.

The Service Layer is your Business Layer ... it's responsibility is to hold all your business logic.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top