I have traditionally implemented a Model-View-Presenter [Passive View] like so:
interface IView
{
string Title {set;}
}
class frmTextBox : Form, IView
{
...
public string Title
{
set { this.txtTitle.Text = value; }
}
...
}
class frmLabel : Form, IView
{
...
public string Title
{
set { this.lblTitle.Text = value; }
}
...
}
class Presenter
{
private IView view;
...
public void UpdateTitle
{
this.view.Title = "A Good Title";
}
...
}
and I have traditionally only used primitive types in the IView
interface (int
, string
, bool
) because I have always understood that you need to use primitive types only in the View. In a Repository (such as NHibernate
), if I want to display a list of items in a DataGridView
, I have to pass a generic collection (IList<T>
) from the Model to the Presenter. Does that violate the rule behind views as consisting only of primitive types or would this architecturally be OK?
Even if I had a Data Transfer Object (DTO), that would be more of a supervising controller rather than passive view style I am trying to implement.
Thoughts??