IView vs. Events?

Jul 13, 2008 at 7:15 PM
Hi Tim-- I'm going back over the Model-View-ModelView pattern, and I am puzzled by something. The ViewModel appears to depend on an IView object, which would presumably reside in the layer just above it. In similar situations, I have used events fired by the Controller (here, the ViewModel), to which the View subscribes. My thinking has been that coupling is reduced by doing that, and that all the dependencies are kept running downhill, as it were.

I am intruiged by your approach, and I am very interested in your thoughts on the subject, particularly on the use of events in this context. Thanks!

Regards,
David Veeneman
Jul 21, 2008 at 5:26 AM

Dave,

Yes, the ViewModel does depend on the IView interface (an abstraction), and this lives in the SmartCA.UI.Infrastructure layer.  In this case, I am using the Command pattern rather than events, and all of the Commands live in the ViewModel implementation and are bound to the implemented views. 

It looks unorthodox at first, but by embracing WPF's data binding capabilities, it actually reduces a lot of code.  Instead of the ViewModel (a la Controller) reacting to the Model, the ViewModel instead reacts to the View.  Make sense?

Thanks,

Tim


dcveeneman wrote:
Hi Tim-- I'm going back over the Model-View-ModelView pattern, and I am puzzled by something. The ViewModel appears to depend on an IView object, which would presumably reside in the layer just above it. In similar situations, I have used events fired by the Controller (here, the ViewModel), to which the View subscribes. My thinking has been that coupling is reduced by doing that, and that all the dependencies are kept running downhill, as it were.

I am intruiged by your approach, and I am very interested in your thoughts on the subject, particularly on the use of events in this context. Thanks!

Regards,
David Veeneman