1 / 38

MVVMmmmmmmmmmmm

MVVMmmmmmmmmmmm. Ward Bell VP Technology, IdeaBlade Twitter: @ wardbell Blog: http://neverindoubtnet.blogspot.com/. Thanks for the slide deck, John Papa. Agenda. MVVM: What and Why Respond to User Actions Abstraction. Design with Data Data Services Testing. Bookshelf in Action.

pillan
Download Presentation

MVVMmmmmmmmmmmm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MVVMmmmmmmmmmmm Ward Bell VP Technology, IdeaBlade Twitter: @wardbell Blog: http://neverindoubtnet.blogspot.com/

  2. Thanks for the slide deck, John Papa

  3. Agenda • MVVM: What and Why • Respond to User Actions • Abstraction • Design with Data • Data Services • Testing

  4. Bookshelf in Action demo

  5. Model View ViewModel

  6. Everybody’s doing it!

  7. MVVM View Model

  8. MVVM • Model • Domain object • Properties • Model Validation View

  9. MVVM • View • The screen or page or control • User friendly presentation of information • Themes and Styles • User interactions Model

  10. MVVM Model View ViewModel

  11. MVVM • ViewModel • Glues the View to the Model • Databound to the View • Properties • Commands • Methods • Contains the Model • Talks to services and load/save the Model Model View

  12. MVVM • View • The screen or page or control • User friendly presentation of information • Themes and Styles • User interactions • Bindings • Events • Behaviors ViewModel Model

  13. Benefits of MVVM

  14. MVVM Presentation logic Binding ViewModel Tell View when data changes Design w/ XAML Model (e.g. PeopleModel/Person) View (e.g. Person Master/Details) XAML Code Not reusable

  15. Binding a View to a ViewModel demo ViewModelLocator INotifyPropertyChanged

  16. Responding to User Actions

  17. Handling User Actions

  18. Commands and Behaviors demo

  19. Services and Separation

  20. + Services MVVM Reusable Services VM V M • ViewModel • Presentation logic • Handle user interaction • Reference Models • Services • Perform operations • Reusable tasks Model View

  21. Separating the Services • Services provide related tasks to the caller • BookDataService, SecurityService, BookEditor • ViewModel uses a Service • Passed through the constructor (Dependency Injection) • ViewModel can focus on bindings and logic • Easily refactored and testable • Services implement an interface

  22. Adding Value with Services demo BookViewModel talks to services

  23. RIA Platforms and MVVM

  24. RIA Platforms • Data access and Server communications • Data modeling as Entities (not DTOs) • Binding directly to Entities • INPC and INDEI • You get EntityManager/DomainContext • Your gateway to the server • Change tracking • Abstraction through Services

  25. DevForce and MVVM demo Behind the BookDataService

  26. + Messaging MVVM VM VM Direct Message? V V M M

  27. + Messaging MVVM EventAggregator Pattern VM VM V V M M Subscribe Messaging Service Publish Subscribe Confirmation Dialog

  28. Confirmation Dialog Example • Define a message type (ConfirmationDialogMessage) • Send method knows MessengerService • Message defines its own payload • Publish message (BookSaver:SaveSuccessful) • Subscribe to message (MainPage:DialogMessageReceived) • Subscriber acquires MessengerService • Subscriber registers action for message

  29. Messaging demo

  30. Blendability & Design Time Data

  31. Design Time Data What am I looking at? Ah! Are my bindings right? How’s my layout? Isn’t this easier/more productive? Notice I’ve tested my Submit Button Logic

  32. Swapping Services • Services won’t run in the Blend and Visual Studio designers • Need design time calls • Service Providers • If DesignTime • Create Design Time Services • Else • Create Regular Services

  33. Blendability: Data in the Designer demo Service Provider and Design Time Services Using cached sample data - “Self-initializing Fake”

  34. Automated Testing demo

  35. Review: Benefits of MVVM

  36. Summary • MVVM: What and Why • Respond to User Actions • Abstraction • Design with Data • Data Services • Testing

  37. Resources Web: IdeaBlade: www.ideablade.com Bookshelf in DevForce: links.ideablade.com/drc-bookshelf SL Firestarter 2010: links.ideablade.com/firestarter10-mvvm MIX 2010 MVVM: links.ideablade.com/mix10-laurent-mvvm MVVM Light: links.ideablade.com/mvvmlight SL Test Framework: links.ideablade.com/sl-utf Print: Silverlight 4 Unleashed, Laurent Bugnion

More Related