如何构建一个企业MVC应用程序,以及哪里业务逻辑去了? [英] How to structure an enterprise MVC app, and where does Business Logic go?

查看:130
本文介绍了如何构建一个企业MVC应用程序,以及哪里业务逻辑去了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个MVC新手。至于我可以告诉大家:

I am an MVC newbie. As far as I can tell:


  • 控制器:具有路由请求交易

  • 查看:涉及数据presentation

  • 型号:看起来完全就像一个数据访问层

  • Controller: deals with routing requests
  • View: deals with presentation of data
  • Model: looks a whole lot like a Data Access layer

在什么地方业务逻辑去?

Where does the Business Logic go?

采取与大型企业应用程序:

Take a large enterprise application with:


  • 数据的多个不同来源的数据访问层捆绑在一起(WCF,Web服务和ADO)(期运用多种不同的DTO)。

  • 很多商业逻辑分割在几个dll文件。

什么是适当的方式为MVC Web应用程序坐在这上面(在code和项目结构方面)?

What is an appropriate way for an MVC web application to sit on top of this (in terms of code and project structure)?

我所看到的例子,一切都只是云在模型文件夹似乎并不像它们适合于非常大的应用程序。

The example I have seen where everything just goes in the Model folder don't seem like they are appropriate for very large applications.

感谢您的任何意见!

推荐答案

在我的应用程序,我通常会建立一个核心项目从Web项目中分离出来。

In my apps, I usually create a "Core" project separate from the web project.

核心项目包含


  1. 业务对象,如实体和这样

  2. 数据访问

  3. 凡是是的的专为网页设计

  1. Business objects, such as entities and such
  2. Data access
  3. Anything that is not specifically designed for web

网络项目包含


  1. 控制器的,它从UI请求路由到核心逻辑

  2. 查看的,其中重点presenting数据HTML

  3. 查看模式的,它压扁/转化的核心业务为对象,旨在支持特定的观点简单结构

  1. Controllers, which route requests from the UI to the core logic
  2. Views, which focus on presenting data in HTML
  3. View Models, which flatten/transform core business objects into simpler structures designed to support specific views

这里的关键点是,基于Web的模型文件夹/命名空间仅用于记录所需要的特定观点的具体变量$ P $特定psentation的模型。尽可能多的商业逻辑地进入核心工程。

The key point here is that the web-based Models folder/namespace is ONLY used for presentation-specific models that document the specific variables needed for a given view. As much "business logic" as possible goes into the core project.

这篇关于如何构建一个企业MVC应用程序,以及哪里业务逻辑去了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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