130 likes | 410 Views
MVVM. Damon Payne Microsoft MVP Principal Architect – BigHammer Data. In the Beginning. Smalltalk MVC Split out (data)model, visual representation, and logic/event handling
E N D
MVVM Damon Payne Microsoft MVP Principal Architect – BigHammer Data
In the Beginning • Smalltalk MVC • Split out (data)model, visual representation, and logic/event handling • Observer – “ Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically” • Command – “Encapsulate a request as an object”
And Then there were more • Model View Presenter • Supervising Controller • Presentation Model (Screen Model) • http://martinfowler.com/eaaDev/PresentationModel.html
Introducing MVVM • John Gossman, 2005 • http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx • Benefits and Goals: • Separate Concerns • Testability • Composition • No code behind! (or as little as possible)
Demo: MVVM Hello World • Let’s rebuild an all code-behind data-entry page • Data sources • Marshaling between screen and DTOs • Validation • Saving data • Some unit tests?
Round 1 - Curiosities • Where do the ViewModels come from? • Dealing with command explosion • Starting Storyboards?
Help With Async Models • Continue Passing • By default WCF runs on the Browser (UI) thread • Model-hydrating callbacks and async validation
MVVM at Design time (Will it blend?) • Not the same as www.willitblend.com • Design time data • Behaviors
Round 2 - Difficulties • How do we deal with Child Windows ? • Component Communication? • (We’ll defer this one till the end) • Parent-child models? • Recommend reusable editors be scoped to Model objects (Demo) • Complex command interactions
Keep the Conversation Going (I’m lonely) • damon@damonpayne.com • http://www.silverlightarchitect.net • http://Feeds.feedburner.com/damonpayne • Twitter.com/damonpayne • Relevant articles: • View-Based Navigation