SlideShare a Scribd company logo
#AndroidArch
#AndroidArch
Implementing Clean
Architecture in
Android
Jorge D. Ortiz-Fuentes
@jdortiz
A Canonical
Examples
production
#AndroidArch
#AndroidArch
Agenda
★ Goals
★ Before Clean Architecture
★ Clean Architecture Concepts
★ Implementation rules
★ Example App: RealProgrammers
★ Implement 1st User Story
★ References
#AndroidArch
Full Version: 3d
★ MVX
• Learn
• Extract MVP
★ 1st User Story
• Use Case
• Presenter
• View
• Entity Gateway
• Initial connection
★ Connectors
• Memory
Management
• Reuse
★ 2nd user story: add
• Navigation: Modal
vs Push
• Command pattern
• Immutables
• Observation
★ 3rd user story: detail
• Identity
• Use case factories
• 2nd use case in the
same view
★ Other use cases: just
logic
★ Forward flow
synchronization
★ Dependency Injection
★ Asynchrony
• Async entity
gateway
• Other tasks
#AndroidArch
LIVE Online Training
★ 3 days (same weekday 3 continuous weeks)
★ 10 people max
★ Live coding shared via video conference
★ Chat running all the time
★ Complete repo with many commits and Tests> 95%
★ Additional exercises
★ Ask as much as you want!
More info at:
http://canonicalexamples.com
Goals
#AndroidArch
Goals
★ Understand the concepts
★ Learn the sources
★ Implement the ideas of the Clean
Architecture in a real app
★ Grow from here
Looking for
volunteer
Warning:
Background Ahead!
Before Clean
Architecture
#AndroidArch
Before Clean Architecture
★ MVC
★ MVP
★ MVVM
– Martin Fowler
“Different people reading about MVC in
different places take different ideas from it and
describe these as 'MVC'. If this doesn't cause
enough confusion you then get the effect of
misunderstandings of MVC that develop
through a system of Chinese whispers.”
#AndroidArch
Tricky question
★ If [Model] + [View] + [Controller /
Presenter / View Model] = [TheApp]
★ How can Controller != Presenter != View
Model?
★ Responsibilities matter!
★ Other components (patterns) might be
involved.
#AndroidArch
The goal
★ Separation of responsibilities into roles. Is
it? Not historically. Other motivations.
Solving problem d’jour.
★ Now why?
• Testability
• Reusability
• Extensibility
#AndroidArch
MVC: The early days
★ Separated presentation: Model <->
Presentation (= V+C)
★ Observer originated from MVC, but
observing full object (properties = scalars)
★ Variations: Passive model, i.e. model cannot
send updates (for example HTTP)
#AndroidArch
Android’s MVC
★ View
• Only View subclasses
• Show information and handle
events to controller
• Fully reusable library of views.
Consistent L&F
★ Controller
• Listeners+Watchers+Adapters
control what’s displayed
• Receive the events and
converts them into calls to the
model
• Observe the model and update
what is displayed on the view
• Implement presentation logic
★ Model
• Implements domain
knowledge / business logic.
Provides data and commands
• Can be observed
• No references to the UI
•Flow synchronization vs
Observer synchronization
Apple’s MVC
Ctrlr
ModelView
#AndroidArch
MVC: testability
★ The views are somebody else's (Google’s)
problem.
★ Model is easy to test.
★ Controller is huge & has dependencies on the
model and on the views => Complex to test.
★ Too many levels of abstraction, only a few
methods exposed.
★ Some stuff in activity that it is usually not tested.
MVP
MVP
Presenter ModelView
Events Operations
Changes Changes
MVVM
MVVM
View Model ModelView
Events & Info Operations
Changes Changes
Clean Architecture
Concepts
#AndroidArch
Clean Architecture
★ Uncle Bob’s (Robert C. Martin’s) architecture
★ Based in Onion, in turn based in hexagonal,
DCI and some others
Clean Architecture
View (A/F) Presenter Interactor
Entity
Gateway
Connector
Persistance FW
View
Network
LocationFW
Presenter
Entity Gateway
Clean Architecture
Interactor
Entity
Implementation
Rules
#AndroidArch
Rules
★ We are going to develop one module at a
time
★ Follow the dependency rules
★ YAGNI
★ No early optimization applied
★ It is easy to add tests, but no TDD in 3h
OK??
Example App:
RealProgrammers
#AndroidArch
Features
★ Add potential candidates (Name, email, and important skills)
★ Show list of programmers with relative interview date
★ Remove candidates from list
★ Edit the data of any candidate
★ Contact candidate by email
★ Sync between devices
★ Universal app (Fragments)
★ Eye candy
★ Android/Android Wear/Android TV/Google Glasses
★ Credits
#AndroidArch
MVP Features
★ Add potential candidates (Name, email, and important skills)
★ Show list of programmers with relative interview date
★ Remove candidates from list
★ Edit the data of any candidate
★ Contact candidate by email
★ Sync between devices
★ Universal app (Fragments)
★ Eye candy
★ Android/Android Wear/Android TV/Google Glasses
★ Credits
Implementing the
1st User Story
I feel like I could
Take On the
World!
#AndroidArch
First User Story
★ Show a list of data elements to the user.
Interactor
View (A/F) Presenter
Show

Programmers
Entity
Gateway
#AndroidArch
Interactor
★ Grab data from the entity gateway
★ Convert it to what is needed to be
presented
★ Pass the results to the presenter
★ Start by defining the interfaces
Presenter
View (A/F)
Programmers

List
Show

Programmers
Entity
Gateway
#AndroidArch
Presenter
★ Direction: only from interactor to view
★ Configure the (dumb) view with the data
provided to it
★ Create the interface for the view (Simplest
wins!)
View
Programmers
ListActivity
Programmers

List
Show

Programmers
Entity
Gateway
#AndroidArch
View
★ Combination of Views + Activity
★ Make it dumb (passive), but useful
★ Tell the presenter about the relevant events
★ Keep them decoupled
Presenter
Programmers
ListActivity
Programmers

List
Show

Programmers
Entity
Gateway
#AndroidArch
Back to the Presenter
★ Implement responses to the user events.
★ Use the interactor
★ Add presentation logic to the presenter part
#AndroidArch
Presentation Logic
★ Date should be relative (“Today”, “1d ago”,
“2w ago”)
★ That means current date is a dependency
that we want to control for tests
★ Use lazy instantiation for the current date
Entity Gateway
Programmers
ListActivity
Programmers

List
Show

Programmers
Entity
Gateway
#AndroidArch
Entity Gateway
★ Basic
★ Defer the decision of the persistence
framework for later.
★ Implement the minimum functionality in a
basic object.
★ Implications of the repository pattern.
References
#AndroidArch
References
★ http://martinfowler.com/eaaDev/
uiArchs.html
★ https://blog.8thlight.com/uncle-bob/
2012/08/13/the-clean-architecture.html
★ https://cleancoders.com/episode/clean-
code-episode-7/show
Thank
you!
@jdortiz
#AndroidArch

More Related Content

What's hot (20)

PPTX
Effective .NET Core Unit Testing with SQLite and Dapper
Mike Melusky
 
PPTX
Back to the ng2 Future
Jeremy Likness
 
PPTX
Clean architecture on android
Benjamin Cheng
 
PDF
Javantura v4 - Android App Development in 2017 - Matej Vidaković
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
Milos Marinkovic "Modular Android UI"
IT Event
 
PDF
Write common, run anywhere
Kouji Matsui
 
PPTX
Annotation processing
Benjamin Cheng
 
PDF
Javantura v4 - Support SpringBoot application development lifecycle using Ora...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PPTX
Angular TS(typescript)
Ivan Stepić
 
PDF
Using TypeScript with Angular
Jamal Sinclair O'Garro
 
PPTX
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
PPTX
Testing Without a GUI Using TestComplete
SmartBear
 
PDF
Javantura v4 - Angular2 - Ionic2 - from birth to stable versions - Hrvoje Pek...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
Integrating react in django while staying sane and happy
Fröjd Interactive
 
PDF
Tweakers Developers Summit 2019 - Angular for backend developers
Bert Jan Schrijver
 
PPTX
What is dev ops?
Mukta Aphale
 
PDF
Android Services Skill Sprint
Jim McKeeth
 
PPTX
Introduction to angular 2
Dor Moshe
 
PDF
Deep Dive into Futures and the Parallel Programming Library
Jim McKeeth
 
PPTX
LogiLogicless UI prototyping with Node.js | SuperSpeaker@CodeCamp Iasi, 2014
Endava
 
Effective .NET Core Unit Testing with SQLite and Dapper
Mike Melusky
 
Back to the ng2 Future
Jeremy Likness
 
Clean architecture on android
Benjamin Cheng
 
Javantura v4 - Android App Development in 2017 - Matej Vidaković
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Milos Marinkovic "Modular Android UI"
IT Event
 
Write common, run anywhere
Kouji Matsui
 
Annotation processing
Benjamin Cheng
 
Javantura v4 - Support SpringBoot application development lifecycle using Ora...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Angular TS(typescript)
Ivan Stepić
 
Using TypeScript with Angular
Jamal Sinclair O'Garro
 
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
Testing Without a GUI Using TestComplete
SmartBear
 
Javantura v4 - Angular2 - Ionic2 - from birth to stable versions - Hrvoje Pek...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Integrating react in django while staying sane and happy
Fröjd Interactive
 
Tweakers Developers Summit 2019 - Angular for backend developers
Bert Jan Schrijver
 
What is dev ops?
Mukta Aphale
 
Android Services Skill Sprint
Jim McKeeth
 
Introduction to angular 2
Dor Moshe
 
Deep Dive into Futures and the Parallel Programming Library
Jim McKeeth
 
LogiLogicless UI prototyping with Node.js | SuperSpeaker@CodeCamp Iasi, 2014
Endava
 

Viewers also liked (15)

PDF
Clean Architecture in Android. UPTech TechTalk
Halyna Halkina
 
PDF
MVP Clean Architecture
Himanshu Dudhat
 
PDF
Architectural superpowers
Jorge Ortiz
 
PDF
TDD for the masses
Jorge Ortiz
 
PDF
Android DevConference - Android Clean Architecture
iMasters
 
PPTX
Onion Architecture
matthidinger
 
PDF
Clean architecture: Android
intive
 
PPTX
Lightning Talk - Clean Architecture and Design
Deivison Sporteman
 
PPTX
рентабельный код
Max Arshinov
 
PDF
Clean Architecture
Badoo
 
PDF
Introducing Clean Architecture
Roc Boronat
 
PPTX
Clean architecture
andbed
 
PDF
Real Life Clean Architecture
Mattia Battiston
 
PPT
Design pattern in android
Jay Kumarr
 
PDF
Android cleanarchitecture
Tomoaki Imai
 
Clean Architecture in Android. UPTech TechTalk
Halyna Halkina
 
MVP Clean Architecture
Himanshu Dudhat
 
Architectural superpowers
Jorge Ortiz
 
TDD for the masses
Jorge Ortiz
 
Android DevConference - Android Clean Architecture
iMasters
 
Onion Architecture
matthidinger
 
Clean architecture: Android
intive
 
Lightning Talk - Clean Architecture and Design
Deivison Sporteman
 
рентабельный код
Max Arshinov
 
Clean Architecture
Badoo
 
Introducing Clean Architecture
Roc Boronat
 
Clean architecture
andbed
 
Real Life Clean Architecture
Mattia Battiston
 
Design pattern in android
Jay Kumarr
 
Android cleanarchitecture
Tomoaki Imai
 
Ad

Similar to Android clean architecture workshop 3h edition (20)

PPT
Android development orientation for starters v4 seminar
Joemarie Amparo
 
PPTX
Presentation on angular 5
Ramesh Adhikari
 
PDF
Creating An App for 650 million customers v.2.pdf
Dmitry Osipa
 
PDF
Ui design patterns
Jorge Ortiz
 
PPTX
.NET? MonoDroid Does
Kevin McMahon
 
PDF
The working architecture of NodeJs applications
Viktor Turskyi
 
PPTX
Angular js
Mauro Servienti
 
PPTX
Angular Owin Katana TypeScript
Justin Wendlandt
 
PDF
"The working architecture of NodeJs applications" Viktor Turskyi
Julia Cherniak
 
PDF
Foss con2011
Vanjikumaran Sivajothy
 
PDF
Introduction to react native
Dani Akash
 
PPTX
Web automation in BDD
Sandy Yu
 
PPTX
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
PDF
Angular mobile angular_u
Doris Chen
 
PDF
Device fragmentation vs clean code
Iordanis (Jordan) Giannakakis
 
PPTX
Mobile UI Testing using Appium and Docker
Moataz Nabil
 
PDF
Refactor your way forward
Jorge Ortiz
 
PDF
Docker Birthday #5 Meetup Cluj - Presentation
Alex Vranceanu
 
PPT
Pertemuan 3 pm
obanganggara
 
Android development orientation for starters v4 seminar
Joemarie Amparo
 
Presentation on angular 5
Ramesh Adhikari
 
Creating An App for 650 million customers v.2.pdf
Dmitry Osipa
 
Ui design patterns
Jorge Ortiz
 
.NET? MonoDroid Does
Kevin McMahon
 
The working architecture of NodeJs applications
Viktor Turskyi
 
Angular js
Mauro Servienti
 
Angular Owin Katana TypeScript
Justin Wendlandt
 
"The working architecture of NodeJs applications" Viktor Turskyi
Julia Cherniak
 
Introduction to react native
Dani Akash
 
Web automation in BDD
Sandy Yu
 
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
Angular mobile angular_u
Doris Chen
 
Device fragmentation vs clean code
Iordanis (Jordan) Giannakakis
 
Mobile UI Testing using Appium and Docker
Moataz Nabil
 
Refactor your way forward
Jorge Ortiz
 
Docker Birthday #5 Meetup Cluj - Presentation
Alex Vranceanu
 
Pertemuan 3 pm
obanganggara
 
Ad

More from Jorge Ortiz (20)

PDF
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz
 
PDF
Unit Test your Views
Jorge Ortiz
 
PDF
Control your Voice like a Bene Gesserit
Jorge Ortiz
 
PDF
Kata gilded rose en Golang
Jorge Ortiz
 
PDF
CYA: Cover Your App
Jorge Ortiz
 
PDF
201710 Fly Me to the View - iOS Conf SG
Jorge Ortiz
 
PDF
Home Improvement: Architecture & Kotlin
Jorge Ortiz
 
PDF
Architectural superpowers
Jorge Ortiz
 
PDF
Architecting Alive Apps
Jorge Ortiz
 
PDF
Escape from Mars
Jorge Ortiz
 
PDF
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
PDF
Dependence day insurgence
Jorge Ortiz
 
PDF
7 Stages of Unit Testing in iOS
Jorge Ortiz
 
PDF
Building for perfection
Jorge Ortiz
 
PDF
TDD by Controlling Dependencies
Jorge Ortiz
 
PDF
Unit testing in swift 2 - The before & after story
Jorge Ortiz
 
PDF
Core Data in Modern Times
Jorge Ortiz
 
PDF
Swift testing ftw
Jorge Ortiz
 
PDF
7 stages of unit testing
Jorge Ortiz
 
PDF
Travel with your mock server
Jorge Ortiz
 
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz
 
Unit Test your Views
Jorge Ortiz
 
Control your Voice like a Bene Gesserit
Jorge Ortiz
 
Kata gilded rose en Golang
Jorge Ortiz
 
CYA: Cover Your App
Jorge Ortiz
 
201710 Fly Me to the View - iOS Conf SG
Jorge Ortiz
 
Home Improvement: Architecture & Kotlin
Jorge Ortiz
 
Architectural superpowers
Jorge Ortiz
 
Architecting Alive Apps
Jorge Ortiz
 
Escape from Mars
Jorge Ortiz
 
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
Dependence day insurgence
Jorge Ortiz
 
7 Stages of Unit Testing in iOS
Jorge Ortiz
 
Building for perfection
Jorge Ortiz
 
TDD by Controlling Dependencies
Jorge Ortiz
 
Unit testing in swift 2 - The before & after story
Jorge Ortiz
 
Core Data in Modern Times
Jorge Ortiz
 
Swift testing ftw
Jorge Ortiz
 
7 stages of unit testing
Jorge Ortiz
 
Travel with your mock server
Jorge Ortiz
 

Recently uploaded (20)

PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
PDF
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
PPTX
Wondershare Filmora Crack 14.5.18 + Key Full Download [Latest 2025]
HyperPc soft
 
PPTX
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
PDF
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
PDF
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
PDF
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
PPTX
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
PPTX
For my supp to finally picking supp that work
necas19388
 
PDF
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
PDF
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
PDF
Rewards and Recognition (2).pdf
ethan Talor
 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
PDF
Mastering VPC Architecture Build for Scale from Day 1.pdf
Devseccops.ai
 
PDF
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
PDF
The Next-Gen HMIS Software AI, Blockchain & Cloud for Housing.pdf
Prudence B2B
 
PPTX
declaration of Variables and constants.pptx
meemee7378
 
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
Wondershare Filmora Crack 14.5.18 + Key Full Download [Latest 2025]
HyperPc soft
 
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
For my supp to finally picking supp that work
necas19388
 
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
Rewards and Recognition (2).pdf
ethan Talor
 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
Mastering VPC Architecture Build for Scale from Day 1.pdf
Devseccops.ai
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
The Next-Gen HMIS Software AI, Blockchain & Cloud for Housing.pdf
Prudence B2B
 
declaration of Variables and constants.pptx
meemee7378
 

Android clean architecture workshop 3h edition