mvvm pattern
TRANSCRIPT
![Page 1: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/1.jpg)
MVVM Pattern
MahenderSenior Software Engineer
United Health Group
![Page 2: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/2.jpg)
Mahender Sarangam• Having 5 years of experience on .NET Technologies.
Working as a Senior Software Engineer in United Health Group (UHG India Information Service Ltd.). Worked with Big Firms like Deloitte Consulting & Wipro Technology.
• Got Technical Acquaintance on Technologies like C#, ASP.NET,AJAX, LINQ, Silverlight, WPF,WCF ,SQL Server, Team Foundation Server(TFS) and SharePoint Technology.
• MCTS Certified in Web Technologies.• Blog : http://Msarangam.wordpress.com
![Page 3: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/3.jpg)
Why Do need PatternEverything in code behind, is not a good idea
![Page 4: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/4.jpg)
![Page 5: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/5.jpg)
Why Do need Pattern• Basic Motivation of separation pattern
– Removing logic from Code behind– Interchanging UI screens– Create Unit test case foe logic and UI– Developers and Designers can work parallel.– Model never needs to be changed to support changes to the
view– No duplicated code to update views
• So what is MVVM ?– Its variation of MVC pattern– John Gossman from WPF team – Resources from external assemblies– Martin Fowler's Presentation Model (PM) pattern
![Page 6: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/6.jpg)
![Page 7: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/7.jpg)
MVC & MVP Difference
![Page 8: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/8.jpg)
![Page 9: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/9.jpg)
Diagram• View Knows VIEW MODEL• VIEW MODEL Knows MODEL• BUT VIEWMODEL does not know View
View View Model Model
![Page 10: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/10.jpg)
View• Represents the user interface that the
user will see.• Can be a user control or Data Template• Keep the view as simple as possible.• Uses Binding to “subscribe” to the
ViewModel• Interprets business data and state of
ViewModel to the human• Nothing but Presentation - XAML• No or minimal code-behind
![Page 11: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/11.jpg)
View Model• An abstraction of View• Connector between View and Model• Keep View State, Value Conversion• No strong or weak (via Interface) reference of
View• Make VM as testable as possible (e.g. no call to
Singleton class)• No Control related Stuff in VM• Provides data to and from the View• Responds to both the View and the Model• Informs the View of changes in the data• Reusable (at least much more than code behind
a form)
![Page 12: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/12.jpg)
Model• Can be Data Model, DTO, POCO,
auto-generated proxy of domain class and UI Model based on how you want to have the separation between Domain Service and Presentation Layer
• No reference to View Model• Typical class that covers a database• Could be a WCF Service and its client
reference
![Page 13: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/13.jpg)
Supporting Libraires and Framework
• WPF Team : MVVM Toolkit• MS Pattern and Practice Team : Composite WPF (Prism)• Josh Smith. "MVVM Foundation"• Sacha Barber. "Cinch."• Karl Shifflett. "Ocean"• Laurent Bugnion. "MVVM Light Toolkit"• Lester Lobo. "CoreMVVM"• Rob Eisenberg. "Caliburn"• William e Kempf. "Onyx"• Peter O’Hanlon. "GoldLight"• jbe. "WPF Application Framework (WAF)"• Paul Stovel : MacroModels
![Page 14: Mvvm pattern](https://reader034.vdocuments.net/reader034/viewer/2022051400/554a54eab4c905522f8b4b40/html5/thumbnails/14.jpg)
Thank you