Exceptions and a view-presenter model (C #)

I applied the MVP (passive scan) pattern in my C # Forms application.

In my case, the model is the laser system of the engine controller, where the model is actually similar to the facade of the other two models (one to the engine control system, and the other to the laser system).

My presenter mediates event models and methods for a view that handles the user interface.

Suppose my view has a laser power setting. The user sets this for a value that is sent to the master, which in turn sends a model request. If the laser power is outside the acceptable range, my model will generate an error that is trapped by my host.

What is the best way for me to notify this message to the user? I thought about making, in my opinion, a method; HandleError (string message) and call it from the master.

This is my first project using MVP, so I have no experience to say which way is the best way.

+3
source share
1 answer

In the view, create a property for the error message. From the master, you can set the value of this property. Back to the idea of ​​the installer for a property, save the value that will be set like any typical property, but add your own logic for any user interface. Then, “View” can control the flow of what is happening within itself.

+6
source

Source: https://habr.com/ru/post/1766906/


All Articles