服务层架构设计混乱
我正在使用 MVC 3。我正在尝试了解服务层和服务。我目前正在研究 DoFactory 源代码附带的示例应用程序。这个问题是基于示例应用程序,但一般而言。
有一个服务层(WCF)公开一组服务方法。服务层实现单一入口点(外观模式),与下面各层的所有通信都必须通过该入口点进行。 Façade 是业务层的入口点,并公开一个非常简单、粗粒度的 API。
假设我正在尝试获取客户端列表,然后在 MVC 控制器中它将调用存储库的 GetCustomers 方法,然后这将调用服务层的 GetCustomers 方法。
我想我在这里有点困惑。这个应用程序架构正确吗?控制器不应该调用服务层的方法,然后调用存储库的方法吗?我一直以为存储库总是最后调用的获取数据的方法?
请有人帮忙澄清一下吗?
I am using MVC 3. I am trying to get my head around the services layer and the service. I am currently working through the sample app that comes with the DoFactory source code. This question is based on the sample application, but in general.
There is a service layer (WCF) that exposes a set of service methods. The service layer implements a single point of entry (the Façade pattern) through which all communication with the layers below must occur. The Façade is the entry point into the business layer and exposes a very simple, course-grained API.
Lets says I am trying to get a list of clients, then in the MVC controller it will call the repository's GetCustomers method, then this will call the service layers GetCustomers method.
I think I am a bit confused here. Is this application architecture correct? Shouldn't the controller call the service layer's method and then this call repository's method. I always thought that the repository was always the last method called to get data?
Please can someone help clarify this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的架构是正确的。
是的,在您的情况下,数据来自 WCF 服务,但它可以是任何内容:SQL 数据库、XML 文件……
Your architecture is correct.
Yes, in your case the data comes from a WCF service but it could be anything: SQL database, XML file, ...