yysun's space

Visual Studio can do MVP

Posted on: February 10, 2008

The code beside technology is used by the visual studio designer. E.g. for each Windows Form, visual studio designer generates two partial classes, one for creating UI elements, and the other one is the place to write code. I think it is a MVP/Passive View already.

  • Windows Froms App, The SomeForm.designer.cs is the view and the SomeForm.cs is the presenter.
  • ASP.NET, the aspx/ascx is the view and the aspx.cs/ascx.cs is the presenter.
  • WPF, the xmal is the view and the xmal.cs is the presenter.

    If it Visual Studio generates an interface, ISomeForm.cs. Then have SomeForm.cs reference to this interface, instead of being partial class of the view. It is exactly MVP/Passive View. This would make unit testing easy based on ISomeForm.cs and SomeForm.cs. I would not mind if Visual Studio does this (in fact it might be something good to suggest MS to do).

    In SCSF and WCSF, there has to be another presenter class. This makes me feel it is a redundant, because presenter class ties/couples to the view. It can hardly be reused. And you have to create extra code to delegate user input/UI events to the presenter. That’s part of reasons why I am not satisfied w/ MVP in SCSF and WCSF.

    The original force of MVP is to ease unit testing. Current unit testing on the presenter is to mock interfaces of view and model. Because there is no other better method, this leaves the mocking on interfaces only one to use practically.

    What about to have a tool that generates mock object from aspx/ascx to make aspx.cs/ascx.cs unit test-able?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


  • None
  • Pk: The horizontal view is a pleasure to use! Good thinking
  • randyburden: A valiant and commendable effort. Your use of Tuple is a little weird but it offers a feature that most other microORMs don't. Your use of a static Gu
  • reav: great work done on Rabbit Framework. just started to learning it, and by now i think it will solve all my problems and questions, that i had in webpag

Categories

%d bloggers like this: