MVC 图 - 它们真的显示了 MVC 的工作原理吗?
当我查看 MVC 图时,我有这样的异议:为什么 Controller 面向用户,而 View 隐藏在后面的某个地方? 在我看来,用户看到视图并与视图交互(这是他在浏览器中看到的),并通过视图用户与控制器“对话”,那么为什么控制器排在第一位呢?
另外,图表不应显示为塔结构(而不是三角形): 视图 - 允许用户与 - 控制器 - 与 - 模型(在底部)交谈 - 然后(反馈)返回到 - 控制器 - 调整为 - 视图
当我看到控制器面向用户的图表时,我总是有这张奇怪的用户图片,一只手拿着 MVC 图,另一只手拿着螺丝刀,打开计算机的盒子并寻找控制器来启动 MVC。
When I look at MVC diagrams I have this objection: why Controller is pictured facing user and View is hidden somewhere behind?
In my opinion user sees and interacts with View (this is what he sees in browser) and via View user "talks" to Controller, so why Controller is first in line?
Also, shouldn't diagram be shown like tower structure (instead of triangle):
View -allows user talking to- Controller - to- Model (on the bottom) - then (feed)back to- Controller -adjustment made to- View
When I see diagram with Controller facing user, I always have this strange picture of user, with a MVC diagram in one hand and screwdriver in another, popping computer's box open and looking for a Controller to get MVC started.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确实不幸的是,大多数文章和书籍仍然使用这种无用的图表来表示 MVC。 MVC 更有用的图实际上是 UML 序列图,就像 Dino Esposito 在他的书中使用的那样 Microsoft .NET:为企业构建应用程序
其次,正如您所指出的,大多数 MVC 文章和书籍都没有更新来描述 MVC 如何在当今的 Web 应用程序中应用,并且仍在谈论关于 MVC,正如 20 多年前最初设想的那样。
我提到的 Esposito 书中有一个关于此的非常好的章节,他描述了 MVC(如最初描述的那样)如何消亡,我们现在应该关注它的现代变体,如 Model2、被动视图和监督控制器。我有一个 在我的博客上回顾本章,您可能会发现有用。
It's really unfortunate that most articles and books still use such useless diagrams to represent MVC. A more useful diagram for MVC is actually a UML sequence diagram like Dino Esposito uses on his book Microsoft .NET: Architecting Applications for the Enterprise
Secondly, as you point out, most MVC articles and books have not been updated to describe how MVC is applied nowadays in web applications and still talk about MVC as it was originally envisioned 20+ years ago.
The Esposito book that I mentioned has a really good chapter about this where he describes how MVC (as originally described) is dead and we should now be focusing in modern variations of it like Model2, Passive View, and Supervising Controller. I've got a review of this chapter on my blog that you might find useful.