MVP, WinForms - how to avoid bloated view, presenter and presentation model

Posted by MatteS on Stack Overflow See other posts from Stack Overflow or by MatteS
Published on 2010-05-31T12:04:57Z Indexed on 2010/06/01 4:23 UTC
Read the original article Hit count: 795

When implementing MVP pattern in winforms I often find bloated view interfaces with too many properties, setters and getters. An easy example with be a view with 3 buttons and 7 textboxes, all having value, enabled and visible properties exposed from the view. Adding validation results for this, and you could easily end up with an interface with 40ish properties. Using the Presentation Model, there'll be a model with the same number of properties aswell.

How do you easily sync the view and the presentation model without having bloated presenter logic that pass all the values back and forth? (With that 80ish line presenter code, imagine with the presenter test that mocks the model and view will look like..160ish lines of code just to mock that transfer.) Is there any framework to handle this without resorting to winforms databinding? (you might want to use different views than a winforms view. According to some, this sync should be the presenters job..) Would you use AutoMapper?

Maybe im asking the wrong questions, but it seems to me MVP easily gets bloated without some good solution here..

© Stack Overflow or respective owner

Related posts about c#

Related posts about mvp