tags:

views:

48

answers:

1

I have implemented the MVP pattern (passive view) in my C# Forms application.

In my case the model is a motor controller laser system, where the model actually is like a facade of two other models (one the motor control system, the other the laser system).

My presenter is a mediator of model-events and methods to the view which handles the user interface.

Suppose my view has a setting for the laser power. The user sets this to some value, which gets sent to the presenter, which in turn send the request to the model. If the laser power is out of range my model throws an error which get catched by my presenter.

How do I best mediate this message to the user? I thought about making, in my view, a method; HandleError(string message), and invoke this from the presenter.

This is my first project using MVP, so I haven't got the experience to say which way is the best way.

+1  A: 

In the view, create a property for an Error Message. From the presenter you can set the value of this property. Back in the view on the setter for the property, store the value that's set as any typical property would do, but in addition add your logic for whatever the user interface needs to do. The View can then control the flow of what happens within itself.

vamuso
That's a good idea. Thanks.
lejon
Let me know if you have any other questions. I worked with the MVP pattern a few years ago and I really liked it. It came into great application when I had to have the same functionality for a Web App and Console application.
vamuso
Additionally this tutorial was very helpful for me: http://polymorphicpodcast.com/shows/mv-patterns/
vamuso