I have a small application that I have written that uses the MVP pattern as follows:
- I created an interface called IView
- I implemented this interface in the Form
- Passed in an instance of the form as type IView into the constructor of the presenter
The form contains a ListView component. The items that populates the ListView are created in the presenter. I heard that it is not a good idea to use UI component classes in the presenter. How and where should I create these ListViewItems? I could create the ListViewItems in the form itself but doesn’t the form need to be as lightweight as possible with no logic in it?
Edit: N.B. This is a Windows Form application
A simple loop, and simple objects creation is not assumed to be difficult. Such code is fairly lilghtweight for a View:
Also, you can use Binding (as others suggested). This will simplify SetData even more.
Try too keep View code such simple that you can ‘validate’ it by fast code review 🙂