凡在MVC中的业务规则 [英] Where are the Business Rules in MVC

查看:189
本文介绍了凡在MVC中的业务规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,每个人都在谈论MVC,我注意到,业务规则没有得到解决。在3层架构的旧时代,业务规则是在中间层。他们在哪里,在新的MVC下降?

Now that everyone is talking about MVC, I notice that the business rules are not being addressed. In the old days of the 3-tier architecture, The business rules were in the middle layer. Where do they fall in the new MVC?

推荐答案

目前先刷,我说,他们在模型中的归属。该 MVC WTO对维基百科似乎都同意:在MVC中,模型再presents信息应用程序的(数据),并用于操纵该数据的业务规则。
毕竟,业务规则我们指的是功能性的算法和逻辑连接code,你的应用程序是参与,而不是输入/输出相关的逻辑域。这些核心业务相关的逻辑不 - 或者基于被显示给用户(这是查看域)或用户输入(这主要是由控制器接收)又该不可─变化

At first brush, I'd say they belong in the model. The MVC Entry on Wikipedia seems to agree: "In MVC, the model represents the information (the data) of the application and the business rules used to manipulate the data". After all, by 'Business rules' we mean the functional algorithms and logic that encode the domain that your application is involved with, as opposed to input/output related logic. These core business-related logic does not - or should not- change based upon what is being displayed to the user (which is the domain of the View) or the user input (which is primarily received by the Controller).

在我的经验,问这样的问题已经在软件开发过程中非常发人深省:我们发现了大量的被一些人认为是业务规则的东西,但竟然是别的东西。如果它不是一个真正的业务规则,它可能不属于该模型

In my experience, asking this sort of question has been very revealing during the software development process: we found a large number of things that were considered 'business rules' by some people, but turned out to be something else. If it is not a true business rule, it might not belong to the model.

这篇关于凡在MVC中的业务规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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