0

I am maintaining an application that I refactored using the MVP pattern. I use the passive view pattern meaning my view is as dumb as possible only forwarding its events via its interface to my presenter.

Right now my presenter got relatively big. Right now I'd like to extract some logic out of it. But that way I would get multiple presenter for a single view.

My root would then construct the view and inject it in several presenter classes, i.e. the first presenter handling only 2 radio buttons, the second presenter only textbox input validation and the third presenter only colors.

Are there any problems I will approach by passing my view around like that to several presenters? I thought view and presenter should always have a 1to1 relationship but never knew or thought about why... Right now I see no reason to not pass the view around and split the logic.

Any thoughts are welcome! Thanks i b advance.

2

1 Answer 1

1

From a SOLID pov you might be breaking the interface segregation principle. Your presenters are receiving the entire view but only using part of its interface. This is not necessarily a problem but it is at least something you should be paying attention to.

You might want to make each presenter take an interface and make the view implement all of them or even split the view into several objects.

It is not that view-presenter relationship should be 1-1 but that you should aim to inject only what the client needs and nothing more.

3
  • I guess you could have a view implement multiple interfaces?
    – Teimpz
    Aug 9, 2018 at 15:55
  • @Teimpz Yes, that's what I mean by "make the view implement all of them". Aug 9, 2018 at 16:34
  • I should learn to read the whole thing before commenting...
    – Teimpz
    Aug 9, 2018 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.