ASP.NET MVC是真正的MVC模式吗? [英] Is ASP.NET MVC a real MVC-Pattern?

查看:53
本文介绍了ASP.NET MVC是真正的MVC模式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几天里,我一直在研究一个小型Web应用程序.我决定使用ASP.NET MVC.我之所以做出此决定,主要是因为我认为这是真正控制Web前端并呈现有效HTML页面的最佳方法.但是,我知道MVC可以更多.

For the last couple of Days I have been working on a small web application. I decided to use ASP.NET MVC. I made this decision mostly because I think it is the best way to really control the web front-end and render valid HTML pages. However, I know that MVC can be much more.

即使我的应用程序很小,但我还是专注于应用程序的体系结构.对我来说很重要的是要有几层,其中两层应该可以随时切换:用户界面(Web/桌面/Webservices)和数据访问逻辑(以支持多个数据库).我认为在Model View Controller模式中这是可能的.

Even though my App is quite small, I am focusing on my application's architecture. It is important to me to have several layers, two of which should be switchable at any time: the user interface (Web / Desktop / Webservices) and the data access logic (to support several databases). I thought that in a Model View Controller pattern this would be possible.

在这种情况下,是否可以将我的基于Web的前端替换为Win32或WPF前端?这可能吗,还是我理解错了?我找不到办法.

In this case will it be possible to replace my web based front-end with a Win32 or WPF front end? Is this possible or did I understand something wrong? I couldn't find a way to do this.

我发现做到这一点的唯一方法是创建MVC层,BusinessLogic层,BusinessObject层和DataAccess层.在那种情况下,所有可以被WPF应用程序重用的通用东西,例如我放入业务层,我放入MVC层的所有MVC特定的东西,而我的控制器所做的大部分工作就是调用BL方法并构建ViewModel.并将其返回到视图.我不确定这是否是正确的解释,并且会感谢您提供有关更好做法的建议.

The only way I found to do this is to create an MVC-Layer, BusinessLogic-Layer, BusinessObject-Layer and a DataAccess-Layer. In that case all generic stuff which can be reused by a WPF App for example I put into the business layer, all the MVC specific Stuff I put in the MVC-Layer, and most what my Controller does is calling BL Methods and building a ViewModel and returning it to the view. I am not sure if this is a correct interpretation and would be thankful for suggestions about better practices.

推荐答案

是的,它采用了真正的MVC模式,至少在Martin Fowler的

Yes, it employs a real MVC pattern, in at least the sense specified by Martin Fowler's Patterns of Enterprise Application Architecture (perhaps the closest thing we have to a canonical definition - see his article 'GUI Architectures' for an extended discussion).

从本质上讲,MVC旨在为用户界面驱动的应用程序建立明确的关注点分离.

At its heart, MVC is about establishing a clear separation of concerns for user-interface-driven applications.

MVC并非旨在使其易于在无状态接口(例如Web应用程序)和胖客户端应用程序(例如WPF或WinForms)之间切换.这些平台有不同的优点和缺点:尝试使用单个控制器来满足这两个要求将导致低于标准的最低公分母实现.

MVC does not purport to make it easy to switch between stateless interfaces (like web applications) and thick client applications (like WPF or WinForms). Those platforms have different strengths and weaknesses: trying to use a single controller to satisfy both would lead to a sub-par lowest-common-denominator implementation.

这篇关于ASP.NET MVC是真正的MVC模式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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