definition - 我无法理解 MVC,它是什么,它不是什么?

标签 definition model-view-controller

我无法理解 MVC 是什么,我应该获得什么样的思维方式或编程模型,以便 MVC 的东西可以立即在我的头上“发光”?如果不是立即,我应该首先尝试做哪些简单的程序/项目,以便我可以将 MVC 带来的简洁的东西应用到编程中。

OOP 直观且容易,对象就在我们身边,使用 OOP 范式的代码重用的好处立即点击给任何人。您可能可以在几分钟内与任何人谈论 OOP,并讲一些示例,他们就会明白。虽然 OOP 以某种方式提高了编程的直观性,但 MVC 似乎恰恰相反。我有负面想法,一些 future 的雇主(甚至客户)会因为我不使用 MVC 技术而看不起我。

虽然我可能得到 skinnable MVC 方面,但是当我尝试将它应用到我自己的项目时,我不知道从哪里开始。

还有一些程序员甚至对如何正确地完成 MVC 有不同的看法。

以 Jeff 关于 MVC 的帖子为例:

The view is simply how you lay the data out, how it is displayed. If you want a subset of some data, for example, my opinion is that is a responsibility of the model.



因此,也许有些程序员使用 MVC,但他们不知何故不经意间使用了 View 或 Controller 来提取数据子集。

为什么我们不能对什么以及如何正确完成 MVC 有一个明确的定义?

而且,当我搜索 MVC .NET 程序时,大部分都适用于 Web 程序,而不是桌面应用程序,这让我更加感兴趣。我的猜测是,这对网络应用程序最有利,桌面应用程序中混合 View (html)和 Controller (程序代码)没有太大问题。

最佳答案

我喜欢 Martin Fowler 所说的方式:)

http://martinfowler.com/eaaCatalog/modelViewController.html

.. 来自 http://martinfowler.com/eaaDev/uiArchs.html :

Take Model-View-Controller as an example. It's often referred to as a pattern, but I don't find it terribly useful to think of it as a pattern because it contains quite a few different ideas. Different people reading about MVC in different places take different ideas from it and describe these as 'MVC'. If this doesn't cause enough confusion you then get the effect of misunderstandings of MVC that develop through a system of Chinese whispers.

关于definition - 我无法理解 MVC,它是什么,它不是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/720640/

相关文章:

definition - Isabelle 中的 "Meta-logic"和 "object-logic"(作为单词)定义

actionscript-3 - 无法找到定义 fl.video.FLVPlayback

c++ - C中isupper的宏定义是什么?

model-view-controller - MVC : Data Models and View Models

c++ - 在mysql服务器源代码中找不到 'ib_lock_t'的定义

python - 有没有办法在Python中打印函数的定义

javascript - 如何根据多个下拉选项显示多个隐藏字段?

javascript - Ember 中同时存在同一 Controller 的多个实例

java - MVC 中有多少 GUI 逻辑太多了?

javascript - 将值从 ViewModel 传递到 JavaScript