SlideShare une entreprise Scribd logo
1  sur  9
Nome
Speaker@twitter
 MVP vs MVVM
a fast introduction
● We are talking about GUIs
Why?
BECAUSE IT’S HARD TO TEST
YOUR GUI !
● GUIs consist of widgets that contain the state of the GUI screen
● Most rich client frameworks encourage putting presentation behavior in
the view class
● Most rich client framework were not build with automated testing in mind
Acronyms
MVP: Model View Presenter
MVVM: Model View ViewModel
Model
● This is the data upon which the user interface will operate.
● It’s purely a domain object and there is no expectation of (or link to) the
user interface at all.
● The intention is that such objects should have no knowledge of the user
interface.
● You can test it in isolation!
(Humble) View
● The view is a humble object:
○ any object that is difficult to test should have minimal behavior.
● Reduce the behavior of the UI components to the absolute minimum
● The view is a dumb slave of the controller:
○ forwards user events to the controller
○ widget updates are pushed by the controller
● Make the view sufficiently humble to help in testing
○ you run little risk by not testing the view
○ if we are unable to include it in our test suites we minimize the
chances of an undetected failure
● It updates the model, and then handles the reloading of the view.
● Easily testable using test double without needing any interaction with
the UI framework
MVP - Presenter
● It receives all user events
○ the view is a dependency of the Presenter
○ data are pulled from the model, and using them to update the
widgets
● It leaves to the view to synchronize all its updates
● It stores the view state (only the once that can change)
MVVM - ViewModel
● It receives all user events
○ abstraction of the view that is not dependent on a specific GUI
framework
○ The view is not a dependency
○ It provides an interface to the view
■ mainly using the observer pattern and data binding
References
● https://www.martinfowler.com/eaaDev/uiArchs.html
● https://martinfowler.com/eaaDev/PassiveScreen.html
● https://martinfowler.com/eaaDev/SupervisingPresenter.html
● https://martinfowler.com/eaaDev/PresentationModel.html
● http://www.object-
arts.com/downloads/papers/TwistingTheTriad.PDF
www.xpeppers.com
/xpepperssrl@xpeppers

Contenu connexe

Similaire à MVP vs MVVM : a fast introduction

Delivering Best Apps with Efficiency
Delivering Best Apps with EfficiencyDelivering Best Apps with Efficiency
Delivering Best Apps with Efficiency
WSO2
 

Similaire à MVP vs MVVM : a fast introduction (20)

Android Architectures
Android ArchitecturesAndroid Architectures
Android Architectures
 
Ui design patterns
Ui design patternsUi design patterns
Ui design patterns
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
software architecture
software architecturesoftware architecture
software architecture
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and Jetpack
 
Firefox OS Window management 201
Firefox OS Window management 201Firefox OS Window management 201
Firefox OS Window management 201
 
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoftMuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
 
Delivering Best Apps with Efficiency
Delivering Best Apps with EfficiencyDelivering Best Apps with Efficiency
Delivering Best Apps with Efficiency
 
FirefoxOS Window Management
FirefoxOS Window ManagementFirefoxOS Window Management
FirefoxOS Window Management
 
Juju: DevOps Destilado
Juju: DevOps DestiladoJuju: DevOps Destilado
Juju: DevOps Destilado
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
App structure Fundamentals
App structure Fundamentals App structure Fundamentals
App structure Fundamentals
 
RxSwift
RxSwiftRxSwift
RxSwift
 
Android Modularization
Android ModularizationAndroid Modularization
Android Modularization
 
'Architecture of modern frontend apps' by YURIY DOBRYANSKYY at OdessaJS'2020
'Architecture of modern frontend apps' by YURIY DOBRYANSKYY at OdessaJS'2020'Architecture of modern frontend apps' by YURIY DOBRYANSKYY at OdessaJS'2020
'Architecture of modern frontend apps' by YURIY DOBRYANSKYY at OdessaJS'2020
 
Lessons-Learned-SwiftUI.pptx
Lessons-Learned-SwiftUI.pptxLessons-Learned-SwiftUI.pptx
Lessons-Learned-SwiftUI.pptx
 
Flex Modular Development and Mate
Flex Modular Development and MateFlex Modular Development and Mate
Flex Modular Development and Mate
 

Dernier

%+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 Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+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
 

Dernier (20)

%+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...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
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...
 
%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
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
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
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
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
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+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...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
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...
 

MVP vs MVVM : a fast introduction

  • 1. Nome Speaker@twitter MVP vs MVVM a fast introduction
  • 2. ● We are talking about GUIs Why? BECAUSE IT’S HARD TO TEST YOUR GUI ! ● GUIs consist of widgets that contain the state of the GUI screen ● Most rich client frameworks encourage putting presentation behavior in the view class ● Most rich client framework were not build with automated testing in mind
  • 3. Acronyms MVP: Model View Presenter MVVM: Model View ViewModel
  • 4. Model ● This is the data upon which the user interface will operate. ● It’s purely a domain object and there is no expectation of (or link to) the user interface at all. ● The intention is that such objects should have no knowledge of the user interface. ● You can test it in isolation!
  • 5. (Humble) View ● The view is a humble object: ○ any object that is difficult to test should have minimal behavior. ● Reduce the behavior of the UI components to the absolute minimum ● The view is a dumb slave of the controller: ○ forwards user events to the controller ○ widget updates are pushed by the controller ● Make the view sufficiently humble to help in testing ○ you run little risk by not testing the view ○ if we are unable to include it in our test suites we minimize the chances of an undetected failure
  • 6. ● It updates the model, and then handles the reloading of the view. ● Easily testable using test double without needing any interaction with the UI framework MVP - Presenter ● It receives all user events ○ the view is a dependency of the Presenter ○ data are pulled from the model, and using them to update the widgets
  • 7. ● It leaves to the view to synchronize all its updates ● It stores the view state (only the once that can change) MVVM - ViewModel ● It receives all user events ○ abstraction of the view that is not dependent on a specific GUI framework ○ The view is not a dependency ○ It provides an interface to the view ■ mainly using the observer pattern and data binding
  • 8. References ● https://www.martinfowler.com/eaaDev/uiArchs.html ● https://martinfowler.com/eaaDev/PassiveScreen.html ● https://martinfowler.com/eaaDev/SupervisingPresenter.html ● https://martinfowler.com/eaaDev/PresentationModel.html ● http://www.object- arts.com/downloads/papers/TwistingTheTriad.PDF

Notes de l'éditeur

  1. Presenter and ViewModel hold presentation behavior
  2. act as a proxy
  3. Supervising Controller or Passive View
  4. Presentation Model and Application Model nel mondo Smalltalk The essence of a Presentation Model is of a fully self-contained class that represents all the data and behavior of the UI window, but without any of the controls used to render that UI on the screen. There isn't a great deal of the difference in test coverage between Presentation Model and Supervising Controller - much of the choice (as with Passive View) depends on personal judgments.