SlideShare a Scribd company logo
1 of 13
©Zühlke 2016
Modernising Android Architecture Using MVVM
and Android Architecture Components
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 1
https://github.com/zuhlke/dagger2_demo
©Zühlke 2016
Agenda
• Model-View-Controller (MVC) briefly
• Model-View-Presenter (MVP)
• dagger2
• Lifecycle events
• Model-View-ViewModel (MVVM)
• Android ViewModel andLiveData
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 2
https://medium.com/@charbgr/bye-bye-dagger-1494118dcd41
©Zühlke 2016
Model-View-Controller
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 3
Controller View
Model
Actions
Update
Read / Write Read / Write
©Zühlke 2016
Model-View-Presenter
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 4
Presenter View
Model
Actions
Update
Read / Write
©Zühlke 2016
Model-View-Presenter
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 5
©Zühlke 2016
Model-View-Presenter
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 6
©Zühlke 2016
MVP with Dagger2
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 7
©Zühlke 2016
MVP with Dagger2
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 8
©Zühlke 2016
MVP with lifecycleevents
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 9
©Zühlke 2016
MVP with lifecycleevents
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 10
©Zühlke 2016
Model-View-ViewModel
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 11
View
Model
Actions
Publish
Read / Write
View
Model
©Zühlke 2016
Model-View-ViewModel
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 12
©Zühlke 2016
Model-View-ViewModel
ModernisingAndroidArchitectureUsing MVVM and AndroidArchitectureComponents 26 Apr2018 Slide 13

More Related Content

Similar to Modernising Android Architecture Using MVVM and Android Architecture Components

Similar to Modernising Android Architecture Using MVVM and Android Architecture Components (20)

SW360 Update Tooling Telco
SW360 Update Tooling TelcoSW360 Update Tooling Telco
SW360 Update Tooling Telco
 
IRJET- Use of Artificial Intelligence in Software Development Life Cycle Requ...
IRJET- Use of Artificial Intelligence in Software Development Life Cycle Requ...IRJET- Use of Artificial Intelligence in Software Development Life Cycle Requ...
IRJET- Use of Artificial Intelligence in Software Development Life Cycle Requ...
 
How to deploy AppInternals in azure
How to deploy AppInternals in azureHow to deploy AppInternals in azure
How to deploy AppInternals in azure
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud FoundryConcevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
 
Microservices and APIs
Microservices and APIsMicroservices and APIs
Microservices and APIs
 
IRJET- A Study Focused on Web Application Development using MVC Design Pa...
IRJET-  	  A Study Focused on Web Application Development using MVC Design Pa...IRJET-  	  A Study Focused on Web Application Development using MVC Design Pa...
IRJET- A Study Focused on Web Application Development using MVC Design Pa...
 
Comprehensive Analysis of Software Development Life Cycle Models
Comprehensive Analysis of Software Development Life Cycle ModelsComprehensive Analysis of Software Development Life Cycle Models
Comprehensive Analysis of Software Development Life Cycle Models
 
ICEC 2014 Linking 6 Phase Project Life Cycle with TCM Framework-Slides
ICEC 2014 Linking 6 Phase Project Life Cycle with TCM Framework-SlidesICEC 2014 Linking 6 Phase Project Life Cycle with TCM Framework-Slides
ICEC 2014 Linking 6 Phase Project Life Cycle with TCM Framework-Slides
 
TechEvent OpenShift for Developers
TechEvent OpenShift for DevelopersTechEvent OpenShift for Developers
TechEvent OpenShift for Developers
 
Continuous Delivery for Machine Learning
Continuous Delivery for Machine LearningContinuous Delivery for Machine Learning
Continuous Delivery for Machine Learning
 
Geek night micro front ends
Geek night   micro front endsGeek night   micro front ends
Geek night micro front ends
 
DX, Guardrails, Golden Paths & Policy in Kubernetes
DX, Guardrails, Golden Paths & Policy in KubernetesDX, Guardrails, Golden Paths & Policy in Kubernetes
DX, Guardrails, Golden Paths & Policy in Kubernetes
 
Aws re invent recap 2016 sm2
Aws re invent recap 2016 sm2Aws re invent recap 2016 sm2
Aws re invent recap 2016 sm2
 
Technology Primer: Monitor Microservices, Containers, Cloud Foundry and Node ...
Technology Primer: Monitor Microservices, Containers, Cloud Foundry and Node ...Technology Primer: Monitor Microservices, Containers, Cloud Foundry and Node ...
Technology Primer: Monitor Microservices, Containers, Cloud Foundry and Node ...
 
Software Factory & TVD-REN the Vaadin framework of Trivadis
Software Factory & TVD-REN the Vaadin framework of TrivadisSoftware Factory & TVD-REN the Vaadin framework of Trivadis
Software Factory & TVD-REN the Vaadin framework of Trivadis
 
SDLC
SDLCSDLC
SDLC
 
SUG Bangalore - Kick Off Session
SUG Bangalore - Kick Off SessionSUG Bangalore - Kick Off Session
SUG Bangalore - Kick Off Session
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
 
DrTAD 3 Blender software. Editor Type
DrTAD 3 Blender software. Editor TypeDrTAD 3 Blender software. Editor Type
DrTAD 3 Blender software. Editor Type
 

Recently uploaded

Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
drm1699
 

Recently uploaded (20)

Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with GraphGraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdf
 
Workshop - Architecting Innovative Graph Applications- GraphSummit Milan
Workshop -  Architecting Innovative Graph Applications- GraphSummit MilanWorkshop -  Architecting Innovative Graph Applications- GraphSummit Milan
Workshop - Architecting Innovative Graph Applications- GraphSummit Milan
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
 

Modernising Android Architecture Using MVVM and Android Architecture Components

Editor's Notes

  1. Introduce myself The objective here is to try and come up with a SOLID, maintainable architecture. At Zuhlke, we do not want to necessarily subscribe to common practice and make the mistake of thinking it’s best practice
  2. Some of you may be more familiar with some of these architecture models than others. Some of this will just be a general run through so that we are talking about the same structures It’s really important that we consider our options for injection before we get really into the new ViewModel and LiveData structures, as we need to have a base for our understanding of each concept
  3. SOLID non conformity Increases distributes potential testing scope Because we are developing Android apps, we would probably use this when we have an activity with lots of fragments so the controller can determine which fragment to display.
  4. Presenters are easy to test in android because a unit test is normally enough. They also contain all the business logic meaning that if there is a bug, we should be checking there The main issue with presenters is that in order to be testable, it needs to be completely agnostic of Android libraries and lifecycle
  5. This is what will be commonly used as our “go back” Notice the Presenter should be fully testable Single Responsibility Problems: Presenter is tied to lifecycle of activity
  6. This is what will be commonly used as our “go back” Notice the Presenter should be fully testable Single Responsibility Problems: Presenter is tied to lifecycle of activity
  7. Not lying: I don’t like Dagger. Not only because of it’s complexity, but also because documentation is fairly scattered Can anyone spot the mistake in my design here? providesMainPresenter should not have a new instance – but how then should it be managed? However this flaw occurs in both my options so it’s not really something that I can use to smash over the head Application has a static reference to appComponent. Would love some suggestions to improving this – this is EXACTLY what we are trying to avoid
  8. Files Changed Gradle changes With dagger: 8 3 Without dagger: 3 0 This is taking into account that you have to modify the Manifest to add the custom application
  9. ViewModel is slightly different from MVP. The ViewModel should have no reference to the View. Instead the View is expected to subscribe to the elements of the ViewModel it is interested in, and it will receive updates The benefits: We are not constantly checking to see if the view is null on the ViewModel side Surviving the orientation changes are now “free” – i.e. internally managed by the OS, not a 3rd party tool There is a slight disadvantage: ViewModels are now Android objects <PAUSE FOR SHOCK> This makes them hard to unit test
  10. ViewModel is slightly different from MVP. The ViewModel should have no reference to the View. Instead the View is expected to subscribe to the elements of the ViewModel it is interested in, and it will receive updates The benefits: We are not constantly checking to see if the view is null on the ViewModel side Surviving the orientation changes are now “free” – i.e. internally managed by the OS, not a 3rd party tool There is a slight disadvantage: ViewModels are now Android objects <PAUSE FOR SHOCK> This makes them hard to unit test
  11. ViewModel is slightly different from MVP. The ViewModel should have no reference to the View. Instead the View is expected to subscribe to the elements of the ViewModel it is interested in, and it will receive updates The benefits: We are not constantly checking to see if the view is null on the ViewModel side Surviving the orientation changes are now “free” – i.e. internally managed by the OS, not a 3rd party tool There is a slight disadvantage: ViewModels are now Android objects <PAUSE FOR SHOCK> This makes them hard to unit test We no longer need to inject Presenters or ViewModels because that gets handled for us. We can focus on injection of things like brokers that manage data, but in a similar manner