I'm currently researching the Model View Presenter design. I am working with .NET C#.
In some of the articles I have read, they give examples of the Presenter setting properties of the View, then in turn the View updates it's controls. For example in the Presenter you might have the following method to update the customer information shown on the view:
1 private void UpdateView(Customer customer)
2 {
3 _view.CompanyName = customer.CompanyName;
4 _view.Address = customer.Address;
5 }
In the view, I would create corresponding setters for CompanyName and Address.
What I am wondering, could I use databinding instead of these setters in the View? I.e. I create CompanyName and Address properties in Presenter (which passes on updates directly to Model), and the View binds it's controls to these properties.
To take this even further, I am wondering if I can bind directly to the properties of the business object (the Model)? In at least some of the articles I've read, it is permissable for the Model to send notifications directly to the View. The Model would not know which views are subscribing to these notifications, so the separation of concerns is still enforced.
It would seem that direct data binding bypasses the role of Presenter, however I would still use Presenter for all other coordination of the UI (for example, deciding when the Save button can be enabled). I am just thinking that when there is a direct relation between controls in the View and properties of the Model, why not use data binding as the coordinating mechanism, rather than a bunch of setters that need to be implemented in the View?
In some of the articles I have read, they give examples of the Presenter setting properties of the View, then in turn the View updates it's controls. For example in the Presenter you might have the following method to update the customer information shown on the view:
1 private void UpdateView(Customer customer)
2 {
3 _view.CompanyName = customer.CompanyName;
4 _view.Address = customer.Address;
5 }
In the view, I would create corresponding setters for CompanyName and Address.
What I am wondering, could I use databinding instead of these setters in the View? I.e. I create CompanyName and Address properties in Presenter (which passes on updates directly to Model), and the View binds it's controls to these properties.
To take this even further, I am wondering if I can bind directly to the properties of the business object (the Model)? In at least some of the articles I've read, it is permissable for the Model to send notifications directly to the View. The Model would not know which views are subscribing to these notifications, so the separation of concerns is still enforced.
It would seem that direct data binding bypasses the role of Presenter, however I would still use Presenter for all other coordination of the UI (for example, deciding when the Save button can be enabled). I am just thinking that when there is a direct relation between controls in the View and properties of the Model, why not use data binding as the coordinating mechanism, rather than a bunch of setters that need to be implemented in the View?