SlideShare a Scribd company logo
6
Most read
9
Most read
24
Most read
MVVM Design Pattern
How can I implement it on Android
Who I am
david.estivariz@24i.com
destivar
David Estivariz
Android developer
Clean coding enthusiast
MVVM Design Pattern
What I’m going to talk about?
Clean code and design patterns, why?
Best practices
MVP vs MVVM
Helping Frameworks or libraries
Android MVVM Architecture example
MVVM Design Pattern
MVVM Design pattern
WHY ??
Why I use a design pattern?
Easier to read/understand
Easier to scale
Easier to test
Easier to find and resolve bugs
Easier to be applied to any other language (object-oriented)
Reduce technical risk
And a long etc…
MVVM Design Pattern
MVVM Design pattern
How do I start?
Escape from spaghetti code!
MVVM Design Pattern
Best Practices
Choose your naming well
Use meaningful names …
but don’t state the obvious
Write small methods
Write methods that only do one thing
Encapsulate boolean expressions or overly-complex code
Avoid deep nesting
Replace constructors with builders (see builder pattern)
Use refactoring patterns to fight against legacy
MVVM Design Pattern
MVP vs MVVM
MVVM Design Pattern
View ViewModel Model
Data Binding and
Commands
ViewModel updates
the model
Send notifications Send notifications
View ModelPresenter
Presenter updates the
model
User events
Updates Fire events
MVVM Design Pattern
MVVM Design Pattern
Butterknife
Butterknife: before & after
MVVM Design Pattern
MVVM Design Pattern
Dagger
Dagger: before & after
MVVM Design Pattern
MVVM Design Pattern
Android Binding
MVVM Design Pattern
View - xml layout
MVVM Design Pattern
View - activity
Android Data Binding framework auto generates
code
Just get Binding object and set params defined at
xml
Then xml will automatically get data from the view
model
MVVM Design Pattern
ViewModel
MVVM Design Pattern
Model
Model mustn’t do anything not related with itself
ViewModel will show model changes in the view
Simple and clean
MVVM Design Pattern
Custom Binding Adapters
Using Custom Binding adapters give you more
flexibility
A binding adapter can use one or more parameters
Their responsibility is to perform actions in the views
depending in parameters from the model
MVVM Design Pattern
Architecture overview
MVVM Design Pattern
Package organisation
MVVM Design Pattern
Any question?
MVVM Design Pattern

More Related Content

What's hot (20)

PPTX
MVVM presentation
Inova LLC
 
PDF
Responsive Design Presentation
Eugen Figursky
 
ODP
Basics of VueJS
Squash Apps Pvt Ltd
 
PPTX
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
PDF
안드로이드 윈도우 마스터 되기
Myungwook Ahn
 
PDF
Jetpack Navigation Component
James Shvarts
 
PDF
Why Vue.js?
Jonathan Goode
 
PPTX
Node js Introduction
sanskriti agarwal
 
PDF
Android Development - ConstraintLayout
Manuel Vicente Vivo
 
PDF
Angular Directives
iFour Technolab Pvt. Ltd.
 
PPTX
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
PPTX
An Overview on Nuxt.js
Squash Apps Pvt Ltd
 
PPTX
HTML and Responsive Design
Mindy McAdams
 
PDF
Angular 10 course_content
NAVEENSAGGAM1
 
PPT
React js
Jai Santhosh
 
PDF
Getting Started with Spring for GraphQL
VMware Tanzu
 
PPTX
Deep dive into swift UI
OsamaGamal26
 
PPTX
Angular modules in depth
Christoffer Noring
 
PDF
Flutter State Management - Moti Bartov, Tikal
DroidConTLV
 
PPTX
Getting Started with React.js
Smile Gupta
 
MVVM presentation
Inova LLC
 
Responsive Design Presentation
Eugen Figursky
 
Basics of VueJS
Squash Apps Pvt Ltd
 
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
안드로이드 윈도우 마스터 되기
Myungwook Ahn
 
Jetpack Navigation Component
James Shvarts
 
Why Vue.js?
Jonathan Goode
 
Node js Introduction
sanskriti agarwal
 
Android Development - ConstraintLayout
Manuel Vicente Vivo
 
Angular Directives
iFour Technolab Pvt. Ltd.
 
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
An Overview on Nuxt.js
Squash Apps Pvt Ltd
 
HTML and Responsive Design
Mindy McAdams
 
Angular 10 course_content
NAVEENSAGGAM1
 
React js
Jai Santhosh
 
Getting Started with Spring for GraphQL
VMware Tanzu
 
Deep dive into swift UI
OsamaGamal26
 
Angular modules in depth
Christoffer Noring
 
Flutter State Management - Moti Bartov, Tikal
DroidConTLV
 
Getting Started with React.js
Smile Gupta
 

Viewers also liked (20)

PDF
Android Data Binding in action using MVVM pattern - droidconUK
Fabio Collini
 
PDF
MVVM & Data Binding Library
10Clouds
 
PDF
Data Binding in Action using MVVM pattern
Fabio Collini
 
PDF
Effective Android UI - English
Pedro Vicente Gómez Sánchez
 
PDF
Android Data Binding
Ezequiel Zanetta
 
PDF
Memory Leaks in Android Applications
Lokesh Ponnada
 
PPTX
FFmpeg presentation
Lauren Sorensen
 
PDF
Deep dive into Android Data Binding
Radek Piekarz
 
PPTX
Android data binding
Sergi Martínez
 
PPT
Android - Thread, Handler and AsyncTask
Hoang Ngo
 
PPT
FFMPEG on android
Yoss Cohen
 
PDF
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
PPTX
Android - Preventing common memory leaks
Ali Muzaffar
 
PPTX
Android Thread
Charile Tsai
 
PPTX
하이브리드앱
knight1128
 
PDF
Android Databinding Library
Takuji Nishibayashi
 
PDF
파크히어 Realm 사용 사례
선협 이
 
PDF
Hockey Kit for Android
旭辰 羅
 
PPTX
2016 Staccato track3 Android를 더 잘 개발하려면? (MVP, MVVM, Clean Architecture)
승용 윤
 
PDF
Android Clean Architecture for Dummies
Kengo Suzuki
 
Android Data Binding in action using MVVM pattern - droidconUK
Fabio Collini
 
MVVM & Data Binding Library
10Clouds
 
Data Binding in Action using MVVM pattern
Fabio Collini
 
Effective Android UI - English
Pedro Vicente Gómez Sánchez
 
Android Data Binding
Ezequiel Zanetta
 
Memory Leaks in Android Applications
Lokesh Ponnada
 
FFmpeg presentation
Lauren Sorensen
 
Deep dive into Android Data Binding
Radek Piekarz
 
Android data binding
Sergi Martínez
 
Android - Thread, Handler and AsyncTask
Hoang Ngo
 
FFMPEG on android
Yoss Cohen
 
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
Android - Preventing common memory leaks
Ali Muzaffar
 
Android Thread
Charile Tsai
 
하이브리드앱
knight1128
 
Android Databinding Library
Takuji Nishibayashi
 
파크히어 Realm 사용 사례
선협 이
 
Hockey Kit for Android
旭辰 羅
 
2016 Staccato track3 Android를 더 잘 개발하려면? (MVP, MVVM, Clean Architecture)
승용 윤
 
Android Clean Architecture for Dummies
Kengo Suzuki
 
Ad

Similar to Android MVVM (20)

PPTX
Android DesignArchitectures.pptx
SafnaSaff1
 
PPTX
Acrhitecture deisign pattern_MVC_MVP_MVVM
Dong-Ho Lee
 
PPTX
Design patterns in android
Zahra Heydari
 
PDF
MVVM Presentation
Javad Arjmandi
 
PPTX
MVVM_Ashraf
Microsoft
 
PPTX
Slide Presentation of MVP Pattern Concept
Bayu Wijaya Permana Putra
 
PDF
Create first android app with MVVM Architecture
khushbu thakker
 
PPTX
Adopting MVVM
John Cumming
 
PDF
Android MVVM
Vinícius Tonial Sossella
 
PPTX
MVVM.pptx
fhaye214
 
PDF
Write cleaner, maintainable, and testable code in Android with MVVM
Adil Mughal
 
PPTX
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Concetto Labs
 
PDF
Portable Class Libraries and MVVM
Andreas Kuntner
 
PDF
MVVM with DataBinding on android
Rodrigo Bressan
 
PPTX
MVVM Presentation.pptx
AsfandyarZaidi
 
PPTX
Marlabs Introduction to Model View ViewModel (MVVM)
Marlabs
 
PPTX
Mobile development strategies with MVVM
James Montemagno
 
PDF
Android App Architecture
Tai Dang
 
PDF
Model View Presenter For Android
InnovationM
 
PDF
Model View Presenter For Android
InnovationM
 
Android DesignArchitectures.pptx
SafnaSaff1
 
Acrhitecture deisign pattern_MVC_MVP_MVVM
Dong-Ho Lee
 
Design patterns in android
Zahra Heydari
 
MVVM Presentation
Javad Arjmandi
 
MVVM_Ashraf
Microsoft
 
Slide Presentation of MVP Pattern Concept
Bayu Wijaya Permana Putra
 
Create first android app with MVVM Architecture
khushbu thakker
 
Adopting MVVM
John Cumming
 
MVVM.pptx
fhaye214
 
Write cleaner, maintainable, and testable code in Android with MVVM
Adil Mughal
 
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Concetto Labs
 
Portable Class Libraries and MVVM
Andreas Kuntner
 
MVVM with DataBinding on android
Rodrigo Bressan
 
MVVM Presentation.pptx
AsfandyarZaidi
 
Marlabs Introduction to Model View ViewModel (MVVM)
Marlabs
 
Mobile development strategies with MVVM
James Montemagno
 
Android App Architecture
Tai Dang
 
Model View Presenter For Android
InnovationM
 
Model View Presenter For Android
InnovationM
 
Ad

Recently uploaded (20)

PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

Android MVVM

Editor's Notes

  • #6: What is not easy? -> well is not easy to start
  • #10: Model View Controller The Model View Controller (commonly known as MVC) framework helps you to build applications that are easier to test and maintain. It comprises of three major components, namely: 1 Model -- this is the layer that represents the application's data 2 View -- this represents the presentation or the user interface layer 3 Controller -- this layer typically contains the business logic of your application The primary objective of the MVC design pattern is separation of concerns to facilitate testability. The Model View Controller design pattern enables you to isolate the concerns and makes your application's code easier to test and maintain. In a typical MVC design, the request first arrives at the controller which binds the model with the corresponding view. In the MVC design pattern, the view and the controller makes use of strategy design and the view and the model are synchronized using the observer design. Hence, we may say that MVC is a compound pattern. The controller and the view are loosely coupled and one controller can be used by multiple views. The view subscribes to the changes in the model. Model View Presenter The MVP (Model View Presenter) design pattern also comprises of three components - the model, the view and the presenter. In the MVP design pattern, the Controller (in MVC) is replaced by the Presenter. Unlike the MVC design pattern, the Presenter refers back to the view due to which mocking of the view is easier and unit testing of applications that leverage the MVP design pattern over the MVC design pattern are much easier. In the MVP design pattern, the presenter manipulates the model and also updates the view. There are two variations of this design. These include the following. 1 Passive View -- in this strategy, the view is not aware of the model and the presenter updates the view to reflect the changes in the model. 2 Supervising Controller -- in this strategy, the view interacts with the model directly to bind data to the data controls without the intervention of the presenter. The presenter is responsible for updating the model. It manipulates the view only if needed -- if you need a complex user interface logic to be executed. While both these variants promote testability of the presentation logic, the passive view variant is preferred over the other variant (supervising controller) as far as testability is concerned primarily because you have all the view updated logic inside the presenter. The MVP design pattern is preferred over MVC when your application needs to provide support for multiple user interface technologies. It is also preferred if you have complex user interface with a lot of user interaction. If you would like to have automated unit test on the user interface of your application, the MVP design pattern is well suited and preferred over the traditional MVC design. RESOURCES Model - View - ViewModel (MVVM) The Model - View - ViewModel (MVVM) is a variation of Martin Fowler's Presentation Model design pattern. The MVVM is a refinement of the popular MVC design and the ViewModel in MVVM is used to facilitation Presentation Separation. In the MVVM the logic is stored in the presenter and the view is completely isolated from the model. While the presenter isn't aware of the view, the view is aware of the presenter -- the presenter in MVVM is used to represent an abstract view of the user interface. A passive view implies that the view doesn't have any knowledge of the model. In the MVVM design pattern, the View is active and contains behaviors, events and data binding information. Note that the view in MVVM is not responsible for managing the state information -- the view is rather synchronized with the viewmodel. The viewmodel in MVVM is responsible for presentation separation and exposes methods and commands to manage the state of a view and manipulate the model. How does the view and the viewmodel in MVVM communicate? Well, the view and the viewmodel in MVVM communicates using methods, properties and events. The bi-directional databinding or the two way databinding between the view and the viewmodel ensures that the models and properties in the viewmodel is in sync with the view. The MVVM design pattern is well suited in applications that need support for bi-directional databinding.
  • #11: I dont have to implement all, if we have tool, libraries, frameworks.. lets use them