Why do we pass the "this" reference to View of Presenter from FormLogin?
I am E-John, a novice of Design Pattern.
I am tracing the Patterns In Action 4.5 WinForms
Some simple questions can not understand,
When "Login" button is pressed, a FormLogin in is created and a LoginPresenter is created.
_loginPresenter = new LoginPresenter(this);
LoginPresenter is inheritanced from Presenter,
LoginPresenter (subclass) -> Presenter (base class)
here the "this" reference is passed to LoginPresenter,
the "this" reference is FormLogin instance here,
Finally the this reference is passed to Presenter(T view)
and view = this is passed to field of Presenter View,
1. Why do we pass the "this" reference to View of Presenter from FormLogin?
2. The parameter of Presenter(T view), T is generic type
The parameter of LoginPresenter is ILoginView, because LoginPresenter : Presenter<ILoginView>
"this" is reference of FormLogin instance,
How is the relations of casting?
Thanks and Best regards,
E-John Lien, May 07, 2018
, This is a great article. It gave me a lot of useful information. thank you very much.
May 15, 2018
The "this" is the actual "View" implementation, which you call your instantiation from, as you use M-V-P pattern.
See the generic description of the pattern here:
Robert Bajomi Christensen, May 11, 2018