就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the help center为指导。
9年前关闭。
混淆是因为互联网上漂浮着不同的 MVC 架构图:
由于这个问题太广泛了,我想集中讨论用于 WebApplications 的 MVC。
说:Zend Framework
.example1:
可能是我见过的最好的。
example 2:
example 3:
模型- View - Controller 概念。实线表示直接关联,虚线表示间接关联(例如通过观察者)。
What I am mainly concentrating is on, how the view interacts with controller(s) & model(s) vice versa.
MVC 与 MVP 的示例:
最佳答案
由于没有发布任何答案,我决定发布一个。这主要是基于
模型- View - Controller (MVC) 架构 (WEB) (PDF)。指向者:Tom Ingram (谢谢)。
文章来自:
约翰·迪肯 (John Deacon) 是一名讲师和作家。面向对象的分析与设计:实用主义
方法。 (有关作者的更多信息,请参阅 About the author
here 部分)
现在,最适合 MVC 架构的图表是:
三部分:Model
- View Controller :
We will call the unchanging essence of the application/domain, the model (in the singular). In object-oriented terms, this will consist of the set of classes which model and support the underlying problem, and which therefore will tend to be stable and as long-lived as the problem itself.
How much should the model (classes) know about the connection to the outside world? Nothing, absolutely nothing.
型号-
View
- Controller :For a given situation, in a given version there will be one or more interfaces with the model, which we'll call the views (plural). In object-oriented terms, these will consist of sets of classes which give us "windows" (very often actual windows) onto the model, e.g.
- The GUI/widget (graphical user interface) view,
- The CLI (command line interface) view,
- The API (application program interface) view.
Or:
- The novice view,
- The expert view.
Although views are very often graphical, they don't have to be.
What will the views know about the model? They have to know of its existence. They have to know something of its nature. A
bookingDate
entry field, for example, might display, and perhaps change, an instance variable of some model class somewhere.
模型- View -
Controller
:A controller is an object that lets you manipulate a view. Over-simplifying a bit, the controller handles the input whilst the view handles the output. Controllers have the most knowledge of platforms and operating systems. Views are fairly independent of whether their event come from Microsoft Windows, X Windows or whatever.
And, just as the views know their model but the model doesn't know its views, the controllers knows their views but the view doesn't know its controller.*
Controllers were Smalltalk specific. They are not of general interest and are not covered in any greater depth here. In Java's Swing architecture, for example, the view and the controller are combined (this is often done in other architectures). In Swing the combined view/controller is called the delegate.
*仔细阅读并消化。
还有关于(通过它们):
“模型”混淆
Smalltalk, then, can be credited with inventing and promoting the MVC architecture. But it could also be accused of confusing things. A better acronym for the architecture would be: MdMaVC.
Md: The domain model.
Ma: The application model.
& 关于通信应该如何发生:
- View to model communication.
- Model (and controller) to view communication.
- Application model to domain model communication.
我认为这应该让我们对
What is the actual pattern for MVC?
有了一个非常清晰的了解。 .
关于model-view-controller - MVC WITH Web 应用程序的实际模式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8692965/