什么是Web应用程序正确的MVC图? [英] What is the right MVC diagram for a web application?

查看:105
本文介绍了什么是Web应用程序正确的MVC图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪个MVC图表正确?每个都有不同的箭头...

Which MVC diagram is correct? Each have different arrows...

图1

图2


(来源: stannard.net.au )


(source: stannard.net.au)

图3

图4


(来源: sun.com )


(source: sun.com)

图5


(来源: shopno-dinga.com )


(source: shopno-dinga.com)

推荐答案

它们都是.

MVC是一种模糊的模式.

MVC is a vague pattern.

我对MVC的看法是:

控制器

对象具有模型的集合,并具有用于查看和编辑模型的方法.它与模型对话,并返回应用了模型的View实例.

Object has a collection of models and has methods for viewing and editing the models. It talks to Models and returns instances of Views with models applied on them.

查看

具有附加的模型定义,只是显示特定模型的一组功能.

Has the definition of a model attached to it and is just a set of functionality to display a specific model.

模型

封装数据.具有返回状态和更改状态的方法.

Encapsulates data. Has methods for returning state and changing state.

//Controller
import Views

class Controller
  private Models

//View
import Model

class View

//Model
class Model

模型不需要了解有关View/Controller的任何信息.视图需要知道模型的定义.控制器需要拥有拥有模型,并且需要了解视图的定义.

A Model doesn't need to know anything about the View / Controller. A View needs to know the definition of a Model. A controller needs to own Models and needs to know definitions of Views.

您可以更紧密地耦合它们,这是可选的.

You can couple them more tightly, that is optional.

这篇关于什么是Web应用程序正确的MVC图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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