什么是MVC web应用WRT的实际模式? [英] What is the actual pattern for MVC WRT WebApplications?

查看:191
本文介绍了什么是MVC web应用WRT的实际模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

混乱是因为不同的MVC建筑风格,图浮在互联网上:
既然问题是过于宽泛我想集中在用于web应用的MVC的。

说: Zend框架

例1:也许是最好的一个我都看到了。

例2:

例子3:

                                    

模型 - 视图 - 控制器的概念。实线重新presents有直接的关联,虚线间接关联(例如经由观察者)。


  

我所主要集中上,视图如何与控制器(S)及相互作用;模式(S),反之亦然。


  
  

      
  • 如果视图直接模式(S)互动?

  •   
  • 如果模型直接更新到视图(S)的任何变化?

  •   
  • 示例2 的MVC的misinter pretation因为它看起来像它的一个MVP 1 2 模式。

  •   

VS MVP MVC的一个例子:


解决方案

由于没有答案贴出来,我决定发布一个。这在很大程度上是基于

模型 - 视图 - 控制器(MVC)体系结构( WEB )(的PDF )。通过指出:汤姆·英格拉姆(感谢)

这篇文章是由:

约翰执事是一名讲师和作家。面向对象分析与设计:语用学
方法。 (更多关于撰文指节作者简介这里

现在,该图最适合MVC架构是:

                  

三个部分:

模式 - 查看 - 控制器:


  

我们将调用应用程序/域的不变的精髓,在模型(单数)。在面向对象的计算,这将包括一组类哪个模型,并支持潜在的问题,因此,这将趋于稳定,并作为长寿命的问题本身。

  模型(类)应该知道多少有关连接到外面的世界?没有,绝对没有。


模型 - 查看 -Controller:


  

对于给定的情况下,在一个给定的版本会有与模型,我们称之为的意见(复数)一个或多个接口。
  在面向对象的术语,这些将包括台班这给我们的窗口(很多时候实际视窗)到模型,例如


  
  

      
  • 的GUI /部件(图形用户界面)视图,

  •   
  • 的CLI(命令行接口)视图,

  •   
  • 的API(应用程序接口)视图。

  •   

  
  

或者


  
  

      
  • 新手来看,

  •   
  • 专家视图。

  •   

  
  

虽然意见非常经常图形,它们不必是


  
  

会的意见,知道怎么样的模式?他们必须知道它的存在。他们必须知道它的本质的东西。 A bookingDate 输入字段,例如,可能会显示,或许改变,一些模型类的实例变量的地方。


模型 - 视图 - 控制器


  

一个控制器是一个对象,它可以让你操纵视图。过度简化了一下,控制器处理输入,而认为处理输出。控制器具有的平台和操作系统最多的知识。视图是相对独立的是否来自微软的Windows,X Windows或任何他们的活动。


  
  

而且,同样的看法知道他们的模型,但模型不知道其观点,控制器知道他们的意见,但认为不知道它的控制器。 *


  
  

控制器是Smalltalk的具体。它们不是普遍关心的,并在任何更大的深度不包括在这里。在Java的摆动结构,例如,视图和控制器相结合(这通常在其他架构完成)。在Swing组合视图/控制器被称为委托。


*请仔细阅读和消化。


还有约(通过他们去):

模型的困惑


  

Smalltalk的话,可以用发明和推广MVC架构抵免。但它也可以被指责的混乱的事情。对于架构一个更好的缩写是:M <子> D M A VC

  中号<子> D :领域模型

  中号 A :应用模型


&安培;如何应该发生通信:


  

      
  • 查看模型的沟通。

  •   
  • 模型(和控制器)来查看通信。

  •   
  • 应用程序模型域模型的沟通。

  •   

我觉得这应该给我们的画面很清晰什么是MVC的实际模式?

The confusion is because of the different MVC architechture diagrams floating on the internet: Since the question would be too broad I want to concentrate on the MVC's used for WebApplications.

Say: Zend Framework.

example1: Probably the best one I have seen.

example 2:

example 3:
                                    
Model-view-controller concept. The solid line represents a direct association, the dashed an indirect association (via an observer for example).

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.

An example of MVC vs MVP:

解决方案

Since no answer was posted, I decided to post one. This is largely based on
Model-View-Controller (MVC) Architecture (WEB) (PDF) . Pointed to by: Tom Ingram (Thanks).

The article is by:
John Deacon is a lecturer and writer. Object-Oriented Analysis and Design: A Pragmatic Approach. (for more on the author refer the section About the author here )

Now, the diagram best suited for the MVC architecture is:
                  

The three parts:

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.

Model-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.

Model-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.

*Read carefully and digest.


There is also about (go through them):

"Model" confusion

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.

& about how the communication should occur:

  • View to model communication.
  • Model (and controller) to view communication.
  • Application model to domain model communication.

I think this should give us a very clear picture of What is the actual pattern for MVC?.

这篇关于什么是MVC web应用WRT的实际模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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