1

我正在尝试学习演示模型模式,在我的尝试中,我对演示模型和 MVP - 被动视图的区别感到困惑。特别是当 Presentation Model 进行同步而不是 View 时。这个问题是对之前关于这个问题的问题的扩展。

Martin Fowler 在他的文章中提供了演示模型进行同步的可能性。

引用视图的表示模型通常在表示模型中维护同步代码。由此产生的观点非常愚蠢。该视图包含任何动态状态的设置器,并引发事件以响应用户操作。视图实现了允许在测试表示模型时轻松存根的接口。Presentation Model 将观察视图并通过更改任何适当的状态并重新加载整个视图来响应事件。因此,无需实际的 UI 类即可轻松测试同步代码。

如果演示模型正在同步,我不完全理解它与 MVP(被动视图)有何不同。他关于 Passive View 的文章展示了一个使用同步来更新视图的示例。

那么表示模型引用视图(和同步)的表示模型模式是否与 MVP(被动视图)相同?

4

1 回答 1

-1

Model-View-Presenter 是一种架构模式,它定义了 UI 级别的行为和逻辑结构。MVP 将表示的逻辑(例如与后端服务和业务层的交互)与显示按钮和界面组件的机制分开。

被动视图是模型-视图-演示者模式的一个子集。 基本模型视图演示者图

从外到内,被动视图的架构如下所示:

UI – The User Interface reflects what is going on beneath it by implementing one or more View interfaces
Presenter – The Presenter receives interactions from the UI or Model and updates the Views it is attached to
Model – The model is a facade or black box in our diagram, behind which is a business logic layer and data layer

在扁平架构中,我们会从接口收集数据,也许会进行一些业务和数据验证,然后使用存储过程或内联 SQL 将其直接保存到数据库中。定义数据访问层(或实体框架之类的数据模型)允许我们的应用程序在对应用程序有意义并一致存储和检索的内聚、已定义对象上进行操作。定义业务逻辑层允许我们以与业务一致且在应用程序内部一致的方式集中对应用程序中的实体进行操作的业务规则,从而将更改业务流程时发生的风险降至最低。

我的示例应用程序有几个功能性和非功能性要求:

Functional – Display product number, name, list price, and available quantity in tabular format
Functional – Provide a basic search input and button to search product names
Non-Functional – Implement an M-V-P pattern – Obviously the purpose of this whole exercise
Non-Functional – Use a simple model stack that can be easily replaced with a Service-Oriented one at a later time
Non-Functional – Build with the idea that we will later create a Silverlight or WPF front-end
Non-Functional – Make pretty pictures for article
于 2016-04-03T03:36:35.823 回答