Phillip Trelford's Array

POKE 36879,255

MVMMC – MVVM grows a Controller

Ray Booysen does it again! The first time I saw Ray do a talk was at NxtGen in Cambridge, when he gave me a timely introduction to MVVM just as I was starting to play with WPF. MVVM (Model-View-View Model) is an architectural pattern, that improves on code behind, making it possible to unit test your UI code (View Model), a good thing. Over a year later and I’m just starting to play with Silverlight, Ray delivers another timely talk on Silverlight gotchas at the Edge UG in London, based on his real-world development experience (developing Financial applications). This time he introduces among other good things MVVMC (MVVM plus Controller). Here the controller takes responsibility for communication between the Model and View Model, leaving the View Model with the single responsibility of providing data to the View.

Somewhat shell shocked I was left with a few questions on implementation details, again Ray to the rescue via Twitter:

ptrelford Excellent @raybooysen Silverlight gotchas talk - MVVMC (C for controller), Network is on UI thread, browser connection limits #edgeug

ptrelford @raybooysen really liked Fat Controller slide, of Thomas the Tank Engine; controller takes responsiblity for marshalling threads etc #edgeug

raybooysen @ptrelford fat controller should be in all slide decks. :)

raybooysen Talk finished at @edge_ug. Think it went ok. Feel like I rambled a little.

ptrelford So with MVVMC the Model is observed by a Controller, which constructs & updates a View Model, which the (XAML) View binds to

raybooysen @ptrelford thanks for coming tonight. :)

ptrelford @raybooysen using MVVMC the Controller observes the Model & updates View Model, which observes user input and passes messages to the Model?

raybooysen @ptrelford viewmodel observes and notifies the the controller.

ptrelford @raybooysen thanks! So View Model takes a reference to the parent controller?

raybooysen @ptrelford no. Can surface the ui interaction via events. Or use rx if you're in for some fun.

ptrelford @raybooysen Cool thanks again! That makes sense, View Model exposes IObservable<T> properties. BTW your talk blew me away (hence questions)!

raybooysen @ptrelford no worries. Iobservable feels quite right in these scenarios. Since controller essentially owns the viewmodel

Finally, this was the same talk that Ray delivered at DDD Scotland, so the slides are already available here

image

image

image

 

image

Pingbacks and trackbacks (3)+

Comments are closed