Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementation differences between MVP Passive View and Supervising Controller for collections
    primarykey
    data
    text
    <p>I've started to wrap my head around the whole <strong>MVP</strong> pattern and despite I'm doing fine with single objects it starts getting difficult when it comes to collections.</p> <p>So let's say we're architecting a simple WinForms application that consists of a DataGrid within a Form, with the data Model being a simple collection of stuff, where such stuff has a bunch of properties and the View is going to actually display them:</p> <p><strong>Model</strong></p> <pre><code>public class Person { public string Name { get; set; } public DateTime Birth { get; set; } public bool IsCool { get; set; } } public class People { public List&lt;Person&gt; Persons { get; set; } } </code></pre> <p><strong>View</strong></p> <pre><code>public interface IPeopleView { List&lt;People&gt; ListOfPeople { get; set; } } public partial class PeopleViewImpl : Form, IPeopleView { private DataGridView _grid = new DataGridView(); public PeopleViewImpl() { InitializeComponent(); } // Implementation of IPeopleView public List&lt;People&gt; ListOfPeople { get { return /* TODO */; } set { _grid.DataSource = value; } } } </code></pre> <p><strong>Presenter</strong></p> <pre><code>public class PeoplePresenter { private People _model; private IPeopleView _view; public PeoplePresenter(People model, IPeopleView view) { _model = model; _view = view; } void UpdateView() { _view.ListOfPeople = _model.Peoples; } } </code></pre> <p>So what should I implement at View's <code>List&lt;People&gt; ListOfPeople</code> getter as well as how should I invoke Presenter's <code>UpdateView()</code>?</p> <p>And generally, which extra Presenter methods would be interesting to have in order to achieve MVP <strong>Passive View</strong> and <strong>Supervising Controller</strong> respectively?</p> <p>Any advice, code style review or opinion will be sincerely appreciated. Thanks much in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload