演示模型与被动视图 [英] Presentation Model vs Passive View

查看:25
本文介绍了演示模型与被动视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道提到的两种模式之间的区别.当您考虑到在表示模型模式中需要同步代码并且该代码在表示模型本身中时,我认为这些模式非常相似.

i am wondering about the difference between the two mentioned patterns. when you consider, that you need synchronization code in the presentation model pattern and that code is in the presentation model itself, then i think the patterns are quite similar.

两者都将事件委托给演示模型/演示者.演示模型和演示者命令域模型并且也观察域模型.在发生更改时,它们都与视图同步(因为表示模型中的同步代码在表示模型中).

Both delegate events to the presentation model / presenter. presentation model and presenter command the domain model and do also observe the domain model. on occuring changes, they both sync with the view (since the synchronisation code in the presentation model is in the presentation model).

在我看来,区别在于,表示模型是视图的抽象形式.它描述了视图的状态和行为.所以它具有所有视图状态信息的属性.并且此信息通过同步代码进行同步.在被动视图中,演示者不一定被视为视图的抽象形式.所以演示者不一定具有表示视图状态的属性.所以演示者不会同步"状态(控件和演示者本身的属性).相反,他只是将域数据复制"(在更改时)到控件中.所以本质上的区别在于视图的抽象,表示模型提供,而在被动视图中,表示器可以被视为域数据的数据映射器.

in my opinion the difference is, that presentation model is an abstract form of the view. it describes the state and behavior of the view. so it has properties for all view state information. and this information is synched via sync code. in passive view, the presenter is not nessessarily seen as an abstract form of the view. so the presenter does not nessessarily have properties representing the view state. so the presenter does not "sync" the states (perperties on controls and the presenter itself). instead he simply "copies" (on changes) domain data to the controls. so the difference is in essence the abstraction of the view, that presentation model provides while in passive view the presenter coud be seen as a data mapper for domain data.

到目前为止还可以,还是我错过了一些重要的事情?

is that ok so far or do i miss something important?

谢谢和最好的问候帕特里克

thanks and best regards patrick

推荐答案

我的理解是 Passive View 是 MVP 的一个变体,而 Presentation Model 是一个单独的模式.

My understanding is that Passive View is a variant of of MVP and Presentation Model is a separate pattern.

正如您所强调的,Presentation Model 具有视图的抽象表示,稍后在 MVVM 中称为 ViewModel.MVP 没有视图的有状态表示,演示者相应地调用视图.被动视图意味着视图调用通常与任何领域概念无关,因此主要是原始类型.而 Supervising Controller 变体允许向视图传递它可以解释的域概念.

As you've highlighted Presentation Model has an abstract representation of the view, later called a ViewModel in MVVM. MVP has no stateful representation of the view, the presenter calls the view accordingly. Passive View means that the view calls are generally agnostic of any domain concepts, so largely primitive types. Whereas the Supervising Controller variant allows the view to be passed domain concepts that it can interpret.

正如我所说,这只是我的理解.我很高兴得到纠正.

As I've said, this is just my understanding. I'm happy to be corrected.

这篇关于演示模型与被动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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