How many presenters should be used in a View Viewer with tabbed Winforms?

I have a tabbed form associated with a business object - for example. A person has biographical data, address data, etc. Each tab handles the input / editing of the Person data category, and each tab can be saved independently. Should one lead be used for all tabs or one lead per tab? There may also be a main tab that can navigate through other tabs (based on the selected data category).

+4
source share
2 answers

I create one presenter for each presentation. If each tab is a separate view, each tab will have its own presenter.

0
source

In my opinion, the logical thing happening here is that you are working with the data of one person. It is random that a user interface view uses a tab, spreadsheet, or a single list of input controls.

The view should depend on switching between tabs, sending data from the master and placing the data that the master gives in the right places.

The host receives the data that sends them, and does all the necessary checks and saves them. He is also responsible for updating the presentation when new data is received.

Thus, if the tab interface does not work, it is easy to switch if the new user interface implements the view interface.

If it is important to update only one tab, then the presenter can be designed with category concepts. As part of the host’s logic, it indicates that the view updates only one category of data.

In a unified entry form, this will be displayed as only one section of the form update. In the tabbed form specified in the original message, this will update one tab.

It is important to strike a balance between the number of classes and their functionality. To few, and they do with many things that will be difficult to separate in future maintenance. Too much and it will become confusing as their relationship again complicates future service.

0
source

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


All Articles