I’ve previously stated that the MVP pattern could be advantages for XAML based applications. I haven’t provided WPF examples yet as I fear that these may compromise the design-ability of the XAML layout.
Florian Krusch describes the beginnings of an MVP style pattern for WPF (and Silverlight) applications in his article:
He states that the pattern described by Martin Fowler “Supervising Controller Pattern” (still under development at time of writing) may be relevant in this case. (The term Controller and Presenter are used interchangeably in Fowler’s article)
This pattern has been created in order to facilitate frameworks such as WPF that have a data binding capability. I understand however that it expects one-way data binding (read) with the view look at the model directly. Updates to fields are delegated to the controller, which in turn updates the model. This sortve neuters the 2-way data binding in WPF.
The true objective of these architectures is testability, with the assumption of the view being difficult to work with in the unit test environment.
An architecture that may work is something like the diagram below:
In this proposal both the View and Model could be mocked successfully.
In future posts I’ll endeavour to create some code to show how this may work in the real world.
|Share this post :|