我怎样称呼构成我的Web应用程序的代码? [英] What do I call the code that orchestrates my web application?

查看:56
本文介绍了我怎样称呼构成我的Web应用程序的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVC中,对于轻量级应用程序,许多人会将其应用程序逻辑放入控制器中。但是实际上,控制器应该是轻量级的,只负责将模型中的逻辑与视图相结合。

In MVC, for a lightweight application, many people will put the logic of their application into the controller. However in reality the controller should be light weight and be only tasked with marrying the logic in the model with the view.

我的问题:模式的名称是什么?在应用程序中协调逻辑的东西应该怎么称呼?从最初的阅读中,我得到了被称为服务的印象,但是自那以来,我已经读了很多东西,使这个想法感到困惑。

My question: What is the name of the pattern/what should I call the thing that orchestrates the logic in my application? From initial reading I got the impression this was called a "Service", however I have read many things since that have muddied that idea.

推荐答案

这取决于您使用的应用程序的类型。如果该应用程序是轻量级应用程序,并且无法维护多年,或者不需要大量业务需求更改的灵活性,那么您几乎可以将自己的逻辑放在任何您喜欢的地方!

That would depend on the kind of application you are working with. If the application is a lightweight application and is not going to be maintained for years or doesn't need flexibility of lot of business requirement changes then you could almost put your logic anywhere you like!

已经说过,很少有这样的应用程序(如果您打算靠它谋生)不需要灵活性。因此,在这一点上似乎有些幼稚,但将来可能会出现其他情况。

Having said that, there are very few such applications (if you intend to earn living out of it) that don't need flexibility. So something that may seem naive at this point but turn out otherwise in future.

使用模式服务的名称很好,但建议您看一下这篇文章在域驱动设计和与此相关的stackoverflow讨论。同样,对于轻量级应用程序,DDD可能会过大,传统的Controller,Service,DAO模式应该足够好。

Coming to the name of the pattern Service is good but would suggest you to look at this article on Domain Driven Design and this related stackoverflow discussion. Again DDD may be overkill for a lightweight application and traditional Controller, Service, DAO pattern should be good enough.

希望有帮助。

这篇关于我怎样称呼构成我的Web应用程序的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆