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

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

问题描述

这个混乱是因为互联网上漂浮的MVC不同的图表:
由于问题太广泛,我想集中在用于Web应用程序的MVC。



说: Zend Framework



example1:可能是我见过的最好的一个。



示例2:



示例3:

                                      

模型视图控制器概念。实线代表一个直接关联,虚拟的间接关联(例如通过观察者)。


我主要集中在,视图与控制器的相互作用模型反之亦然。




  • 视图是否直接与模型进行交互?

  • 模型是否会直接更新视图的任何更改?

  • 是否在示例2 中的图表被误解的MVC,因为它看起来像是一个MVP ()( PDF )。指向:汤姆·英格拉姆(感谢)。



    文章由:
    John Deacon是一名讲师和作家。面向对象的分析与设计:实用的
    方法。 (关于作者的更多内容,请参阅部分关于作者 here



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



    三部分:



    模型 -View-Controller:




    我们将调用应用/域的不变本质,单数)。在面向对象的术语中,这将包括一组模型和支持底层问题的类,因此它将趋向于与问题本身一样稳定和长寿。_
    多少模型(类)应该知道与外界的连接吗?没有,绝对没有。




    模型 - 查看 -Controller:




    对于给定的情况,在给定的版本中,将有一个或多个与模型的接口,我们将其称为视图(复数)。
    在面向对象的术语中,这些将由给我们的窗口(通常是实际的窗口)的模型组成,例如




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

    • CLI(命令行界面)视图

    • API (应用程序界面)视图。



    或:




    • 新手视图

    • 专家视图。



    虽然视图非常通常是图形化的,它们不一定是。



    这些模型的意见是什么?他们必须知道它的存在。他们必须知道其本质。例如,一个 bookingDate 输入字段可能会在某个地方显示某个模型类的实例变量,也可能会更改。




    模型视图 - 控制器




    控制器是一个允许您操纵视图的对象。过度简化了一点,控制器处理输入,同时视图处理输出。控制器具有最多的平台和操作系统知识。视图是否与他们的活动来自于Microsoft Windows,X Windows或其他任何内容是相当独立的。



    正如视图知道他们的模型,但是模型不知道它的意见,控制器知道他们的意见,但视图不知道它的控制器。 *



    控制器是Smalltalk具体。他们不是普遍的兴趣,在这里没有任何更深入的涵盖。例如,在Java的Swing架构中,组合视图和控制器(这通常在其他体系结构中完成)。在Swing中,组合的视图/控制器称为委托。


    *仔细阅读并消化。






    还有关于(通过他们):



    模型混乱




    然后,Smalltalk可以发明和推广MVC架构。但也可以指责混乱的事情。该架构的更好的首字母缩略词是:M a VC。

    M :域模型。
    M 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 WRT WebApplications的实际模式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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