model-view-controller - MVC WITH Web 应用程序的实际模式是什么?

标签 model-view-controller design-patterns architecture mvp

就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the help center为指导。




9年前关闭。




混淆是因为互联网上漂浮着不同的 MVC 架构图:
由于这个问题太广泛了,我想集中讨论用于 WebApplications 的 MVC。

说:Zend Framework .
example1:可能是我见过的最好的。
MVC
example 2: MVC
example 3:MVC
模型- View - Controller 概念。实线表示直接关联,虚线表示间接关联(例如通过观察者)。

What I am mainly concentrating is on, how the view interacts with controller(s) & model(s) vice versa.

  • Should the view interact directly with model(s)?
  • Should the model directly update any changes to the view(s)?
  • Is the diagram in example2 a misinterpretation of MVC as it looks like its a MVP(1)(2)pattern.


MVC 与 MVP 的示例:
enter image description here

最佳答案

由于没有发布任何答案,我决定发布一个。这主要是基于
模型- View - Controller (MVC) 架构 (WEB) (PDF)。指向者:Tom Ingram (谢谢)。

文章来自:
约翰·迪肯 (John Deacon) 是一名讲师和作家。面向对象的分析与设计:实用主义
方法。 (有关作者的更多信息,请参阅 About the author here 部分)

现在,最适合 MVC 架构的图表是:
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/

相关文章:

java - Spring中将Controller1的方法调用到Controller2的另一个方法中

java - 服务类应该在java中是单例的吗?

ruby-on-rails - 在哪里放置可重用的方法以供 rails 中的 Controller 访问

asp.net-mvc - 使用隐式/显式转换运算符是否违反单一职责模式而支持 DRY?

ruby-on-rails - Ruby on Rails : The same check in multiple actions in a controller

java - 有没有Android MVC框架?

design-patterns - Singleton 类的多个实例。可能的?

java - 谁应该决定?调用者还是方法的业务逻辑?建筑风格

asp.net-mvc - EntityFramework SaveChanges() 抛出并发事务错误

multithreading - 消费者生产者 : Pausing the consumer if memory usage goes beyond a particular threshold