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.
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.
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!
精彩评论