Date post: | 07-May-2015 |
Category: |
Technology |
Upload: | matt-casto |
View: | 8,725 times |
Download: | 0 times |
Creating Applications using the Model-View-ViewModel Pattern
Matt Castohttp://google.com/profiles/mattcasto
Developing Software is HARD
Developing Software is HARD
Patterns Help … but its still HARD!
Model – View – ViewModel
Model – View – Controller
Model – View – Controller•Regarded as the first pattern to
seperate UI, Data & Logic concerns•Controller handles all logic,
including Mouse & Keyboard events
Model – View – Presenter
Model – View – Presenter•Variation of MVC• Tailored for modern UI that handles
Mouse & Keyboard events better•Presenter depends on View
Presentation Model
Presentation Model•Published by Martin Fowler in 2004•View is a rendering of the
Presentation Model
Presentation Model“Probably the most annoying part of Presentation Model is the synchronization between Presentation Model and view. It’s simple code to write, but I always like to minimize this kind of boring repetitive code. Ideally some kind of framework could handle this, which I’m hoping will happen someday with technologies like .NET’s data binding.”
– Martin Fowler
Model
Model – Your Data
Model – Your Data• Entities• Service Proxy•POCO
Model – Your DataView
Model – Your DataView – User Interface
Model – Your DataView – User Interface
•XAML (WPF)•XAML w/ Code Behind (Silverlight)
Model – Your DataView – User InterfaceViewModel
Model – Your DataView – User InterfaceViewModel – The View’s Model
Model – Your DataView – User InterfaceViewModel – The View’s Model
• State•Operations•Not Dependent on the View
You’re probably already doing something very close to this
You probably could be doing something very close to this
Why do I care about MVVM?
Why should you care about MVVM?
Patterns are a set of guidelinesPatterns are not a set of rules
Benefits of MVVM
Benefits of MVVM
• Loose Coupling• Testable Code• Maintainable Code
Developers and Designers
DEMO
WPF vs Silverlight
DEMO
Adding Validation
DEMO
Unit Testing
DEMO
Commands
MVVM Solutions
• Component Application Guidance• MVVM Light Toolkit• Caliburn• Roll Your Own
Sources• WPF Apps With The Model-View-ViewModel Design Pattern – Josh Smith
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
• Model-View-ViewModel In Silverlight 2 Apps – Shawn Wildermuthhttp://msdn.microsoft.com/en-us/magazine/dd458800.aspx
• ViewModel Pattern in Silverlight using Behaviors – Nikhil Kotharihttp://www.nikhilk.net/Silverlight-ViewModel-Pattern.aspx
• Using RoutedCommands with a ViewModel in WPF – Josh Smithhttp://www.codeproject.com/KB/WPF/VMCommanding.aspx
• Presentation Model – Martin Fowlerhttp://martinfowler.com/eaaDev/PresentationModel.html
THANKS!!
Matt Castohttp://google.com/profiles/mattcasto