Wednesday, October 29, 2008

MVP And Databinding

While working on a rather large winform application, whose presentation tier is using Model View Presenter Pattern (MVP), my team and I discovered the blasphemy that is databinding when used with MVP. A lot of the developers on my team are pro-data binding as it makes their life easy on the first round of development for any given screen. What we found was that as the screen evolved and requirements changed (as they always seejm to do), the databinding began to become unweildy, and nasty. Complex page interaction between controls would quickly rear their ugly heads, and all of the sudden you'd be writing all sorts of code to support "most of the databinding" rather than just adding new interations.

I began plotting against databinding all together when the perfect argument popped into my head. Databinding breaks MVP. Think about it... If the view has knowledge of business objects, or worse updates them w/ new information it has garnered from user interaction, the presenter has be removed from it's primary interaction. Let us not forget my presenters job is to handle all the heavy lifting when it comes to dealing w/ data, model obects, and the interaction between the models services, and the view. Also, my presenter gives me a great way to unit test presentation logic. Once removed, how the heck to you unit test a view. It seems to me currency managment is a violation of MVP.