为什么MVC如此受欢迎? [英] Why is MVC so popular?

查看:35
本文介绍了为什么MVC如此受欢迎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我原本打算把这个问题写得更长,但我觉得我写得越短,你就越能理解我的意思.

I was originally going to make this a longer question, but I feel like the shorter I make it, the better you'll understand what I mean.

  • MVC 架构模式有 3 个依赖项.视图取决于模型.控制器依赖于视图和模型.模型是独立的.

  • The MVC architectural pattern has 3 dependencies. The View depends on the model. The Controller depends on the View and Model. The Model is independent.

层架构模式定义了 N - 1 个依赖项,其中 N 是层的数量.

The Layers architectural pattern defines N - 1 dependencies, where N is the number of Layers.

给定三层:模型、视图和控制器,只有 2 个依赖项,而传统 MVC 有 3 个依赖项.结构如下:

Given three Layers: Model, View, and Controller, there are only 2 dependencies, as opposed to 3 with traditional MVC. The structure looks like this:

View ---> Controller ---> Model

[View 依赖 Controller,Controller 依赖 Model]

[View depends on Controller, Controller depends on Model]

在我看来,这种风格实现了相同的目标并且产生了更松散的耦合.为什么这种风格不更常见?它真的实现了相同的目标吗?

It seems to me that this style accomplishes the same goals and produces looser coupling. Why isn't this style more common? Does it truly accomplish the same goals?

不是 ASP.NET MVC,只是模式.

Not ASP.NET MVC, just the pattern.

关于格里格斯的帖子:

  • 就模拟而言,Layer 仍然允许您使用命令处理器模式来模拟按钮点击以及任何其他范围的事件.
  • UI 更改仍然非常容易,甚至可能更容易.在 MVC 中,控制器和视图倾向于结合在一起.层创建了严格的分离.两个层都是黑匣子,在实现中可以自由变化.
  • 控制器对视图的依赖为 0.视图可以写,松散耦合仍然可以节省时间.

推荐答案

我已经很久没有回过头来了,主要是因为我还在思考.我对收到的答案不满意,他们没有真正回答我的问题.

I haven't gotten back to this in a long time, mostly because I was still thinking. I was unsatisfied with the answers I received, they didn't really answer my question.

最近,一位教授确实将我引向了正确的方向.本质上,他告诉我:将模型、视图和控制器分开的层 MVC.在 vanilla MVC 架构模式中,通常不使用 View 到 Model 之间的依赖关系,您实际上以层结束.思路是一样的,就是命名不好.

A professor, recently, did steer me in the right direction. Essentially, he told me this: Layers which separate Model, View, and Controller is MVC. In the vanilla MVC architectural pattern, the dependency between the View to the Model is often not used, and you effectively end up with Layers. The idea is the same, the naming is just poor.

这篇关于为什么MVC如此受欢迎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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