ViewDiscoveryComposition Employees Controller AND Presenter?

Topics: Prism v2 - Silverlight 2, Prism v2 - WPF 3.5
Mar 20, 2009 at 3:25 PM
I am currently going through the Prism samples and am confused by something in the ViewDiscoveryComposition sample. The Employee module contains both a EmployeesController and a EmployeesPresenter and I'm not entirely sure why.

The EmployeesPresenter presents the EmployeesPresentationModel to the EmployeesView, which binds the RegionContext of "SelectionPanel" region (populated with an EmployeesDetailsView by the EmployeesDetailsPresenter), but simply passes off SelectedEmployee change notifications to the EmployeeController, which then in turn loads a new EmployeeDetailsPresenter into the SelectionPanel region.

Despite the obvious confusion that Prism is using MVC+MVP+MVVM, is there a diagram or video that explains the difference in responsibilities of presenters vs controllers within Prism?
Mar 23, 2009 at 8:47 PM

Hi Richard,

 

You are probably right, and this approach is a bit of an overkill for this particular situation. But one of the things the Prism-v2 team looked to accomplish with it was to show how composite views and scoped regions work, and this made this simple master-details scenario in something somewhat contrived, with very cohesive views coming from different places. It also shows that combining all these elements and patterns is a doable approach. (Say that someone felt comfortable with MVP but still wants to take advantage of the WPF binding capabilities that is best accustomed in the ViewModel).

 

Although it is kind of confusing, try to think that in this particular scenario the EmployeesController is acting as a controller for the entire module (or cross module). If the module had some extra functionality that needed to be managed at a higher level than each of the views (or presenters really), this would be the best place to do it. As for the presenter and the view-model, as you said the EmployeesPresenter is only setting the model to the view, but it could handle more complex logic.

 

Example: if clicking a button in the view, was meant to load a different module, that logic should normally not be handled by the view. But, if the view notified the presenter, which in turn would notify the controller to load a new module that would be a better approach.

 

Please let me know if this helps.

 

Damian Schenkelman

http://blogs.southworks.net/dschenkelman
Mar 23, 2009 at 9:13 PM
Hi Damian,

Thanks for that, it makes alot more sense now. Is the responsibility of the EmplyeesModule, then, only to handle initialisation?

Cheers,
Rich