MVP pattern. Presenter requires new view instance. Best practice
- by Andrew Florko
I try to apply MVP pattern for win.forms application. I have 2 forms: main & child. Main has a button and when you click it - child form should appear.
There are 2 views interfaces that forms implement
IMainView {
event OnClick;
...
}
IChildView {
...
}
There are two presenters
MainPresenter(IMainView) & ChildPresenter(IChildView)
MainPresenter listens to OnClick event and then should create IChildView implementation.
MainPresenter {
...
MainClicked() {
// it's required to create IChildView instance here
}
}
How would you implement such creation typically?
Shall IMainView has factory method for IChildView or may be it should be separate Views factory. What would you advise? Or maybe there is some misunderstanding of MVP here?
Thank you in advance!