什么是用户界面设计模式,如MVC,MVP,MVVM模型? [英] What is Model in user interface design patterns like MVC, MVP, MVVM?

查看:307
本文介绍了什么是用户界面设计模式,如MVC,MVP,MVVM模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了很多的使用模型 - 视图UI设计模式教程和例子,它们都实现这些pretty的不同,特别是模型的一部分​​。在一些例子模型数据(重一些的DB presentation实际对象)的一些它的数据访问层(如存储库模式)的一些它的服务层...
如果有人告诉你他正在使用的MV *模式在他的应用程序,会是什么告诉你的应用程序的设计?它是否保持在内存中再$ P $数据库psentation的对象图,并把它作为数据源或一些数据访问层来查询数据库...

什么,你会选择的一种模式导向的内容主要是标签页以表?智能客户端应用程序的数据。

解决方案

字模型中使用

,至少两种意义。还有就是你的域模型。在这里,感觉是你如何重新present您的数据。有许多方法来组织你的数据,并通过多种方法访问它。当我们谈论的模型,在这个意义上,我们不是特别关心如何你正在访问的弥补,即结构,数据访问或持久层,虽然你也可以听到人们说话的持久性的模式。由此,人们意味着持久性实现使用,如ActiveRecord的或存储库的具体理念。你也可以听到这些被称为模式。

最后,字模型具有非常特定的含义在MVC中,MVP,而MVVM在视图的上下文中。在这种情况下,这意味着与一个视图时,视图模型相关联的那个特定的数据对象。这可以是你的域对象之一,但更典型地它是一个封装的数据从一个或多个域对象连同辅助数据,例如用户数据所使用的一个特定视图的视图的特定对象。

有关您的应用程序,选择持久性模型最适合您的开发环境和语言 - LINQ到SQL,LINQ到实体,NHibernate的,城堡的ActiveRecord等在MS世界创建视图的具体型号(班)的每个你的观点,即需要举行由该视图中的数据。用你的控制器来查询你的域模型来提取所需要的视图的信息,并映射到视图模型。

I have seen lots of tutorials and examples using Model-View UI design patterns, and they all implement them pretty differently, especially the Model part. In some examples Model is data (actual object representation of some DB) in some it's data access layer (like repository pattern) in some it's service layer...
If someone tells you he is using MV* pattern in his app, what will it tell you about app design? Does it maintain in-memory representation of database in object graph and use it as data source or some data access layer to query data base...

What you will choose as a Model for data oriented smart client app containing mostly Tab Pages with Tables?

解决方案

The word model is used in, at least, two senses. There is your domain model. Here the sense is how you represent your data. There are many ways to structure your data and also many ways to access it. When we talk about the model in this sense we're not particularly concerned with how you are accessing the structures that make it up, i.e., the data access or persistence layer, although you may also hear people speak of the model of persistence. By this, people mean the particular philosophy that the persistence implementation uses, such as ActiveRecord or Repository. You might also hear these referred to as patterns.

Finally, the word model has a very specific meaning in MVC, MVP, and MVVM in the context of a view. In that context it means that particular data object associated with a view, the view model. This could be one of your domain objects, but more typically it is a view-specific object that encapsulates data from one or more domain objects along with ancillary data such as user data that is used by a particular view.

For your application, choose the persistence model that best suits your development environment and language -- LINQ to SQL, LINQ to Entities, nHibernate, Castle ActiveRecord, etc. in the MS world Create view-specific models (classes) for each of your views that hold the data needed by that view. Use your controllers to query your domain model to extract the information needed by the view and map that onto the view model.

这篇关于什么是用户界面设计模式,如MVC,MVP,MVVM模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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