SlideShare una empresa de Scribd logo
1 de 29
What? and Why ?
Agenda 
 
 Intro : Traditional UI development. 
MVVM in Deep : 
 What is MVVM? 
 Model / View Model /View. 
 Classes interaction . 
MVVM and other patterns. 
MVVM Advantages /Disadvantages. 
MVVM in Android. 
 Conclusion & Recommendations.
Traditional UI Development 
 
Simple , no problem
Traditional UI Development 
 
More work , more problems
Traditional UI Development 
 
Model View 
UI 
Layout 
Code 
behind 
Domain 
objects 
Update and get data
Traditional UI Development 
 
 Constraints: 
 Difficult to Test 
 Encourages using UI as data storage 
 Complex classes and a huge mount of code. 
 No code sharing . 
 very strong dependency between UI & logic. 
 What if you need to redesign UI?
What ? And How?
What is MVVM? 
 
 The Model View ViewModel. 
 Introduced by Microsoft in 2006. 
 Not a design pattern it is an 
architectural pattern. 
 It is a specialization of the 
presentation model pattern.
MVVM In Deep 
 
 Components to be swapped 
 Internal implementation to 
be changed without 
affecting the others 
 Components to be worked 
on independently 
 Isolated unit testing
MVVM In Deep 

Model 
 
 Non-visual classes that encapsulate the 
application's data and business logic. 
 Can’t See View Model or View. 
 Should not contain any use case–specific or user 
task–specific behavior or application logic. 
 Notifies other components of any state changes. 
 May provide data validation and error reporting
View Model 
 
 Non-visual class encapsulates the 
presentation logic required. 
 Can’t See View (no direct Reference). 
 Coordinates the view's interaction 
with the model. 
 May provide data validation and 
error reporting. 
 Notifies the view of any state changes.
View 
 
 Visual element defines the controls 
and their visual layout and styling. 
 Can see all others components. 
 Defines and handles UI visual 
behavior, such as animations or 
transitions. 
 Code behind may contain code that 
requires direct references to the 
specific UI controls.
Classes Interaction 
 
Interaction Ways 
Data Binding Commands Notifications
What about MVP & MVC ?
MVP vs. MVC vs. MVVM 

MVP vs. MVC vs. MVVM 
 
MVP (Presenter) MVC (Controller) MVVM (View Model) 
view communicates with the 
view sends input events to 
View binds directly to the 
presenter by directly calling 
the controller via a callback 
View Model. 
functions on an instance of 
or registered handler 
the presenter. 
The presenter communicates 
with the view by talking to 
an interface implemented by 
the view 
View receives updates 
directly from the model 
without having to go 
through the controller 
changes in view are 
automatically reflected in 
View Model and changes 
and Vice versa. 
Use where binding via a data 
context is not possible 
Use where the connection 
between view and the rest 
of the program is not 
always available 
Use where binding via a 
data context is possible
Why ? And Why not?
MVVM Advantages 
 
 Separation of concerns. 
 Can use unit tests. 
 Designers and developers can work 
synchronously. 
 Easy to redesign the UI . 
 Can share code easily.
MVVM Disadvantages 
 
 Harder to debug. 
 May affect performance. 
 More files to serve the architecture.
MVVM in Android 
 
MVVMCross for Xamarin.Android. 
 Dot42 Framework. (C# for android). 
 Android-binding. 
 Robo Binding
Conclusion & 
Recommendations 
 
MVVM is a suitable architectural pattern for 
business apps. 
 Use MVVM only when you need it. 
 Using MVVM is highly recommended in Cross- 
Platform development. 
MVVM is a tool not a purpose.
References 
 
 http://www.codeproject.com/Articles/100175/Model-View-ViewModel-MVVM-Explained 
 http://blogs.adobe.com/paulw/archives/2007/10/presentation_pa_3.html 
 http://en.wikipedia.org/wiki/Model_View_ViewModel 
 http://aspnet.blogershub.com/Archive/2013/12/what-is-difference-Application-Architecture-and- 
Design-Patterns 
 http://msdn.microsoft.com/en-us/library/hh848246.aspx 
 http://msdn.microsoft.com/en-us/library/ms752347(v=vs.110).aspx 
 http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh758320.aspx 
 http://msdn.microsoft.com/en-us/library/gg405484(v=pandp.40).aspx 
 http://joel.inpointform.net/software-development/mvvm-vs-mvp-vs-mvc-the-differences-explained/
Design Patterns VS. 
Architectural Patterns 
 
Design Patterns 
 Guidelines to avoid/solve 
common problems in 
application development. 
 Tell us how we can 
achieve a solution in 
terms of implementation. 
 Implementation Level. 
Architectural Patterns 
 Guidelines to construct 
the structure and 
behavior of applications. 
 Tell us how to arrange the 
interaction between 
application packages, 
databases, and 
middleware systems . 
 Abstract Level.
Presentation Model Pattern 
 
 Introduce by Martin Fowler in 2004. 
 An abstract of the view that is not dependent on a specific 
GUI framework. 
 State is in the presentation model. 
 Logic is in the presentation model. 
 View observes the model and updates accordingly. 
 The view “knows” about the presentation model. 
 The presentation model does not “know” about the view. 
 presentation model Also Known as application model, 
view state or logical View.
Data Binding (State) 
 
 Process that establishes a connection between the 
application UI and application logic. 
When the data changes its value, the elements that 
are bound to the data reflect changes automatically.
Data Binding (State) 
 
 Direction of the data flow: 
 One Time bindings update the target with the source 
data when the binding is created. 
 One Way bindings update the target with the source 
data when the binding is created, and any time the 
data changes. This is the default mode. 
 Two Way bindings update both the target and the 
source when either changes.
Commands (Behavior) 
 
 Provide a way to represent actions or operations that 
can be easily bound to controls in the UI. 
 Encapsulate the actual code that implements the 
action or operation . 
 Examples : Button Click , List selection changed.
Notifications 
 
 Implementing INotifyPropertyChanged and 
INotifyCollectionChanged interface. 
 OnPropertyChanged method is required to notify 
binding target properties with change in source. 
 Observable Collection needed for binding lists source.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architecture
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVM
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPF
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
Angular components
Angular componentsAngular components
Angular components
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.js
 
Vue.js Getting Started
Vue.js Getting StartedVue.js Getting Started
Vue.js Getting Started
 
Full session asp net mvc vs aspnet core
Full session asp net mvc vs aspnet coreFull session asp net mvc vs aspnet core
Full session asp net mvc vs aspnet core
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Mvc, mvp, mvvm...
Mvc, mvp, mvvm...Mvc, mvp, mvvm...
Mvc, mvp, mvvm...
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Vue JS Intro
Vue JS IntroVue JS Intro
Vue JS Intro
 

Destacado

MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões ArquiteturaisMVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
Jorge Tressino Rua
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicated
mdc11
 

Destacado (20)

Pattern MVVM avec MVVM Light Toolkit
Pattern MVVM avec MVVM Light ToolkitPattern MVVM avec MVVM Light Toolkit
Pattern MVVM avec MVVM Light Toolkit
 
WPF MVVM
WPF MVVMWPF MVVM
WPF MVVM
 
Windows 8 store apps development
Windows 8 store apps developmentWindows 8 store apps development
Windows 8 store apps development
 
Exploring MVVM, MVC, MVP Patterns - CRB Tech
Exploring MVVM, MVC, MVP Patterns - CRB TechExploring MVVM, MVC, MVP Patterns - CRB Tech
Exploring MVVM, MVC, MVP Patterns - CRB Tech
 
Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVM
 
Caliburn.Micro
Caliburn.MicroCaliburn.Micro
Caliburn.Micro
 
MVVM de A à Z
MVVM de A à ZMVVM de A à Z
MVVM de A à Z
 
Présentation WPF
Présentation  WPFPrésentation  WPF
Présentation WPF
 
MVVM par Karim PIerre Maalej
MVVM par Karim PIerre MaalejMVVM par Karim PIerre Maalej
MVVM par Karim PIerre Maalej
 
Varjú Zoltán - Túlélőkészlet adatáradat esetére
Varjú Zoltán - Túlélőkészlet adatáradat esetéreVarjú Zoltán - Túlélőkészlet adatáradat esetére
Varjú Zoltán - Túlélőkészlet adatáradat esetére
 
MVVM Light for UWP
MVVM Light for UWPMVVM Light for UWP
MVVM Light for UWP
 
Data binding
Data bindingData binding
Data binding
 
MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões ArquiteturaisMVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicated
 
MVVM Lights
MVVM LightsMVVM Lights
MVVM Lights
 
Dominando o Data Binding no Android
Dominando o Data Binding no AndroidDominando o Data Binding no Android
Dominando o Data Binding no Android
 
Android Databinding Library
Android Databinding LibraryAndroid Databinding Library
Android Databinding Library
 
Testable Android Apps using data binding and MVVM
Testable Android Apps using data binding and MVVMTestable Android Apps using data binding and MVVM
Testable Android Apps using data binding and MVVM
 
MVVM & Data Binding Library
MVVM & Data Binding Library MVVM & Data Binding Library
MVVM & Data Binding Library
 
Deep dive into Android Data Binding
Deep dive into Android Data BindingDeep dive into Android Data Binding
Deep dive into Android Data Binding
 

Similar a MVVM ( Model View ViewModel )

Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
RapidValue
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10
Bryan Anderson
 
Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)
Shubham Goenka
 

Similar a MVVM ( Model View ViewModel ) (20)

Code Camp 06 Model View Presenter Architecture
Code Camp 06   Model View Presenter ArchitectureCode Camp 06   Model View Presenter Architecture
Code Camp 06 Model View Presenter Architecture
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
 
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Mvc vs mvp vs mvvm  a guide on architecture presentation patternsMvc vs mvp vs mvvm  a guide on architecture presentation patterns
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
 
Mvvw patterns
Mvvw patternsMvvw patterns
Mvvw patterns
 
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
реалии использования Mv в i os разработке
реалии использования Mv в i os разработкереалии использования Mv в i os разработке
реалии использования Mv в i os разработке
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10
 
Mvc, mvp & mvvm (erp)
Mvc, mvp & mvvm (erp)Mvc, mvp & mvvm (erp)
Mvc, mvp & mvvm (erp)
 
Design patterns in android
Design patterns in androidDesign patterns in android
Design patterns in android
 
SUE AGILE MVVM (English)
SUE AGILE MVVM (English)SUE AGILE MVVM (English)
SUE AGILE MVVM (English)
 
Android MVVM
Android MVVMAndroid MVVM
Android MVVM
 
Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)
 
MVVM Presentation.pptx
MVVM Presentation.pptxMVVM Presentation.pptx
MVVM Presentation.pptx
 
Portable Class Libraries and MVVM
Portable Class Libraries and MVVMPortable Class Libraries and MVVM
Portable Class Libraries and MVVM
 
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
 

Último

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

MVVM ( Model View ViewModel )

  • 2. Agenda   Intro : Traditional UI development. MVVM in Deep :  What is MVVM?  Model / View Model /View.  Classes interaction . MVVM and other patterns. MVVM Advantages /Disadvantages. MVVM in Android.  Conclusion & Recommendations.
  • 3. Traditional UI Development  Simple , no problem
  • 4. Traditional UI Development  More work , more problems
  • 5. Traditional UI Development  Model View UI Layout Code behind Domain objects Update and get data
  • 6. Traditional UI Development   Constraints:  Difficult to Test  Encourages using UI as data storage  Complex classes and a huge mount of code.  No code sharing .  very strong dependency between UI & logic.  What if you need to redesign UI?
  • 7. What ? And How?
  • 8. What is MVVM?   The Model View ViewModel.  Introduced by Microsoft in 2006.  Not a design pattern it is an architectural pattern.  It is a specialization of the presentation model pattern.
  • 9. MVVM In Deep   Components to be swapped  Internal implementation to be changed without affecting the others  Components to be worked on independently  Isolated unit testing
  • 11. Model   Non-visual classes that encapsulate the application's data and business logic.  Can’t See View Model or View.  Should not contain any use case–specific or user task–specific behavior or application logic.  Notifies other components of any state changes.  May provide data validation and error reporting
  • 12. View Model   Non-visual class encapsulates the presentation logic required.  Can’t See View (no direct Reference).  Coordinates the view's interaction with the model.  May provide data validation and error reporting.  Notifies the view of any state changes.
  • 13. View   Visual element defines the controls and their visual layout and styling.  Can see all others components.  Defines and handles UI visual behavior, such as animations or transitions.  Code behind may contain code that requires direct references to the specific UI controls.
  • 14. Classes Interaction  Interaction Ways Data Binding Commands Notifications
  • 15. What about MVP & MVC ?
  • 16. MVP vs. MVC vs. MVVM 
  • 17. MVP vs. MVC vs. MVVM  MVP (Presenter) MVC (Controller) MVVM (View Model) view communicates with the view sends input events to View binds directly to the presenter by directly calling the controller via a callback View Model. functions on an instance of or registered handler the presenter. The presenter communicates with the view by talking to an interface implemented by the view View receives updates directly from the model without having to go through the controller changes in view are automatically reflected in View Model and changes and Vice versa. Use where binding via a data context is not possible Use where the connection between view and the rest of the program is not always available Use where binding via a data context is possible
  • 18. Why ? And Why not?
  • 19. MVVM Advantages   Separation of concerns.  Can use unit tests.  Designers and developers can work synchronously.  Easy to redesign the UI .  Can share code easily.
  • 20. MVVM Disadvantages   Harder to debug.  May affect performance.  More files to serve the architecture.
  • 21. MVVM in Android  MVVMCross for Xamarin.Android.  Dot42 Framework. (C# for android).  Android-binding.  Robo Binding
  • 22. Conclusion & Recommendations  MVVM is a suitable architectural pattern for business apps.  Use MVVM only when you need it.  Using MVVM is highly recommended in Cross- Platform development. MVVM is a tool not a purpose.
  • 23. References   http://www.codeproject.com/Articles/100175/Model-View-ViewModel-MVVM-Explained  http://blogs.adobe.com/paulw/archives/2007/10/presentation_pa_3.html  http://en.wikipedia.org/wiki/Model_View_ViewModel  http://aspnet.blogershub.com/Archive/2013/12/what-is-difference-Application-Architecture-and- Design-Patterns  http://msdn.microsoft.com/en-us/library/hh848246.aspx  http://msdn.microsoft.com/en-us/library/ms752347(v=vs.110).aspx  http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh758320.aspx  http://msdn.microsoft.com/en-us/library/gg405484(v=pandp.40).aspx  http://joel.inpointform.net/software-development/mvvm-vs-mvp-vs-mvc-the-differences-explained/
  • 24. Design Patterns VS. Architectural Patterns  Design Patterns  Guidelines to avoid/solve common problems in application development.  Tell us how we can achieve a solution in terms of implementation.  Implementation Level. Architectural Patterns  Guidelines to construct the structure and behavior of applications.  Tell us how to arrange the interaction between application packages, databases, and middleware systems .  Abstract Level.
  • 25. Presentation Model Pattern   Introduce by Martin Fowler in 2004.  An abstract of the view that is not dependent on a specific GUI framework.  State is in the presentation model.  Logic is in the presentation model.  View observes the model and updates accordingly.  The view “knows” about the presentation model.  The presentation model does not “know” about the view.  presentation model Also Known as application model, view state or logical View.
  • 26. Data Binding (State)   Process that establishes a connection between the application UI and application logic. When the data changes its value, the elements that are bound to the data reflect changes automatically.
  • 27. Data Binding (State)   Direction of the data flow:  One Time bindings update the target with the source data when the binding is created.  One Way bindings update the target with the source data when the binding is created, and any time the data changes. This is the default mode.  Two Way bindings update both the target and the source when either changes.
  • 28. Commands (Behavior)   Provide a way to represent actions or operations that can be easily bound to controls in the UI.  Encapsulate the actual code that implements the action or operation .  Examples : Button Click , List selection changed.
  • 29. Notifications   Implementing INotifyPropertyChanged and INotifyCollectionChanged interface.  OnPropertyChanged method is required to notify binding target properties with change in source.  Observable Collection needed for binding lists source.