Implementing a service layer in an MVC architecture

后端 未结 3 980
闹比i
闹比i 2020-12-15 09:00

How would one typically implement a service layer in an MVC architecture? Is it one object that serves all requests to underlying business objects? Or is more like an object

3条回答
  •  无人及你
    2020-12-15 09:39

    The way I read this question, there's really two things that should be answered:

    A) I would prefer splitting "Service" into "CustomerService" and "OrderService", in other words grouped by domain concepts.

    B) Secondly I'd use dependency injection to get the proper service directly where I need it, so I'm basically using alt 1. The added abstraction in alternative 2 provides no additional value for me, since the IoC container does the important part.

提交回复
热议问题