MVC 的最佳定义是什么? [英] What is the best definition of MVC?

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

问题描述

我一直在使用带有 MVC 配置的 Zend 框架,阅读了有关 Ruby on Rails 的信息,并且我计划探索 Python(Django?)中的其他 MVC 框架.我真的很喜欢它隔离逻辑、安全性和验证的某些部分的方式.但是在使用它一年后,我在这里阅读了一个答案 说几乎每个人都对 MVC 有错误的定义,这让我想知道:MVC 的正确定义是什么,我在哪里可以阅读有关模式和标准实现的信息?

I have been using the Zend Framework with an MVC configuration, read about Ruby on Rails and I plan to explore other MVC frameworks in Python (Django?). I really like the way it isolates some parts of the logic, security, and validation. But after just one year of using it I read an answer here saying that almost everyone has a wrong definition of MVC and that made me wonder: What is the Right definition of MVC and where could I read about the pattern and standard implementations?

更新:我知道我们都知道 BASIC 的定义(有一个模型、一个控制器和一个视图,控制器上的动作在用模型做了一些事情后会转到带有一些信息的视图)但是我很想知道你认为每个人都知道的定义是什么,为什么它是错的(也许这会向每个人解释哪里可能存在错误、意见,当然还有你对此的真实观点)

Update: I understand we all know the BASIC definition (there's a model a controller and a view, the actions on the controller go to the view with some info after making something with the model) but I would love to know what is the definition you THINK everyone KNOWS and why is it wrong (and maybe that will explain to everyone where there could be mistakes, opinions, and of course what is your real point of view of this)

推荐答案

请参阅本书的第 14 章:企业应用程序架构模式,作者 Martin Fowler.

See Chapter 14 of the book: Patterns of Enterprise Application Architecture, by Martin Fowler.

MVC 部分开始于:

"模型视图控制器 (MVC) 是其中之一被引用最多的(也是最被错误引用的)周围的图案.它开始是一个Trygve 开发的框架用于 Smalltalk 平台的 Reenskaug在 1970 年代后期.从那以后它有在大多数 UI 中发挥了重要作用框架和思考用户界面设计."

"Model View Controller (MVC) is one of the most quoted (and most misquoted) patterns around. It started as a framework developed by Trygve Reenskaug for the Smalltalk platform in the late 1970s. Since then it has played an influential role in most UI frameworks and in the thinking about UI design."

它还说:

当我想到 MVC 时,我看到了两个主要分离:分离模型的演示和将控制器与查看.

"As I think about MVC I see two principal separations: separating the presentation from the model and separating the controller from the view.

...

其中的分离演示文稿和模型是其中之一最重要的设计原则软件,唯一一次你不应该遵循它很简单模型没有真实的系统无论如何.只要你得到一些你应该的非视觉逻辑应用分离.不幸的是,一个很多 UI 框架都做到了困难,那些不困难的经常在没有分离的情况下教.

Of these the separation of presentation and model is one of the most important design principles in software, and the only time you shouldn't follow it is in very simple systems where the model has no real behavior in it anyway. As soon as you get some nonvisual logic you should apply the separation. Unfortunately, a lot of UI frameworks make it difficult, and those that don't are often taught without a separation.

视图和控制器的分离不那么重要,所以我只会建议在真正需要时进行有帮助.对于富客户端系统,最终几乎没有,虽然这在 Web 前端很常见,其中控制器分离出来.最多这里的网页设计模式是基于该原则."

The separation of view and controller is less important, so I'd only recommend doing it when it is really helpful. For rich-client systems, that ends up being hardly ever, although it's common in Web front ends where the controller is separated out. Most of the patterns on Web design here are based on that principle."

这篇关于MVC 的最佳定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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