开发者

Implementing the MVP pattern on a multipage ASPx website

开发者 https://www.devze.com 2023-03-10 18:11 出处:网络
I am currently redesigning a piece of software from an aspx application, to support winforms as well, and by doing this I am implementing the MVP pattern to easier handle further development and make

I am currently redesigning a piece of software from an aspx application, to support winforms as well, and by doing this I am implementing the MVP pattern to easier handle further development and make it easier to maintain two versions of the same application.

But this the first time I am implementing this pattern, so a couple of questions manifest themselves.

  1. Since this application has several pages/forms, should I have one presenter per view (one view = one a开发者_StackOverflowspx file)? I am guessing yes to make is easier to maintain and to keep the IView interfaces tidyer.

  2. What is the 'standard' detail I should write the IView at? ie. To test this I am writing the RegisterUser.aspx view, and there are some controls I want to disable at certain times, should I have a generic 'void DisableControl(string name); void EnableControl(string name);' or a more specialized 'void DisablePasswordControl(); void EnablePasswordControl();'?

I can see pros and cons to both approaches, so I thought I should at least ask before I make any bad habits here.


1 Yes

2 I would go with a property like this:

public class RegisterUser : IRegisterUserView
{
   bool IRegisterUserView.PasswordEnabled
   {
     get { return tbPassword.Visible ; }
     set { tbPassword.Visible = value; }
   }
}


For point 1 it should be 1 presenter per view, unless you have a very similar presenter which would use an identical view.

For point 2, you should have this as just either the void DisableControl(string name) although this isn't too necessary as it can all be handled within your aspx.cs part of the page. It depends what and when you are hiding the control.

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消