What is good practice for separating presenters in an MVP interface template that has become too large?

One of the problems that I often encounter recently is the problem that my lead classes are getting too big. Usually I can slice an ordinary large class without gaps. But presenters are sometimes a little harder to figure out without making the code harder to follow.

Especially when the page begins to fill with CRUD-oriented controls. Sometimes I separate controls, but if other controls affect them, the coordination logic is complex in itself. Sometimes I share the search for a list or grid data, but sometimes it can have similar pitfalls.

Are there any methods or rules of thumb or common areas that you reorganize from your presenters?

+3
source share
2 answers

I usually use two approaches:

  • Extract and delegate business rules to domain classes.
  • Divide the view into logically related controls, then create a new view interface for each section. Then you can divide the presenter along the same lines. If the platform you are using supports subgroup component groups (C # user controls, Delphi frames, etc.), this is a powerful way to make reusable elements.

Update

.

public class ComplexForm: Form, ISubView, IOtherSubView
{
    ...
}

, .

public class SubViewPresenter
{
    private ISubView subView;
    ...
}

public class OtherSubViewPresenter
{
    private IOtherSubView otherSubView;
    ...
}

ISubView IOtherSubView . , , . , . - , .

+9

, DAL . , -, . / .

, .

+2

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


All Articles