MVP pattern. Presenter requires new view instance. Best practice
Posted
by Andrew Florko
on Stack Overflow
See other posts from Stack Overflow
or by Andrew Florko
Published on 2010-06-05T17:30:22Z
Indexed on
2010/06/05
17:32 UTC
Read the original article
Hit count: 236
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!
© Stack Overflow or respective owner