MVC

MVC

Model - The model represents data and the rules that govern access to and updates of this data. In enterprise software, a model often serves as a software approximation of a real-world process.
模型——模型表示数据和控制对数据的访问和更新的规则。在企业软件中,模型通常指模拟真实过程的近似值。

View - The view renders the contents of a model. It specifies exactly how the model data should be presented. If the model data changes, the view must update its presentation as needed. This can be achieved by using a push model, in which the view registers itself with the model for change notifications, or a pull model, in which the view is responsible for calling the model when it needs to retrieve the most current data.
视图——视图呈现模型的内容。它精确地指定了模型数据应该如何显示。如果模型数据发生变化,视图必须根据需要更新其表示。这可以通过使用推模型来实现,在推模型中,视图向模型注册自己以获得更改通知;或者使用拉模型,在拉模型中,视图负责在需要检索最新数据时调用模型。

Controller - The controller translates the user's interactions with the view into actions that the model will perform. In a stand-alone GUI client, user interactions could be button clicks or menu selections, whereas in an enterprise web application, they appear as GET and POST HTTP requests. Depending on the context, a controller may also select a new view -- for example, a web page of results -- to present back to the user.
控制器——控制器将用户与视图的交互转换为模型将执行的操作。在独立的GUI客户机中,用户交互可以是按钮单击或菜单选择,而在企业web应用程序中,它们显示为GET和POST HTTP请求。根据上下文的不同,控制器还可以选择一个新视图(例如,一个结果web页面)返回给用户。


MVP

MVP

The model is an interface defining the data to be displayed or otherwise acted upon in the user interface.
The view is a passive interface that displays data (the model) and routes user commands (events) to the presenter to act upon that data.
The presenter acts upon the model and the view. It retrieves data from repositories (the model), and formats it for display in the view.

与MVC最大的不同在于,view和model是不能直接通信的,所有的view改变都是通过presenter来改变的。


MVVM

MVVM


参考链接

https://www.oracle.com/technical-resources/articles/javase/application-design-with-mvc.html
https://en.wikipedia.org/wiki/Model-view-presenter
https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel

最后修改:2020 年 05 月 16 日
如果觉得我的文章对你有用,请随意赞赏