Responsibilities of Service and Repository layers

后端 未结 1 1171
刺人心
刺人心 2021-02-06 02:00

Just trying to get my head round the responsibilities of the service layer and repository layer when saving an object to my persistence store.

My current under standing

1条回答
  •  爱一瞬间的悲伤
    2021-02-06 02:42

    Your separation of concerns sounds pretty good to me. We follow the same pattern, but tend to add one more layer right about the repository layer. We call it the domain layer and perform all our business logic in there. Our service layer is just a pass through to our domain in case we need to publish any of our services to an ESB in the future.

    The biggest benefit of what you are doing is not cluttering all the business and DB logic in the controller which a lot of people tend to do. You always want your controllers to be as light as possible if you really want to follow MVC.

    0 讨论(0)
提交回复
热议问题