際際滷

際際滷Share a Scribd company logo
CLEAN ARCHITECTURE
AYUSH MAHARJAN
CLEAN ARCHITECTURE
POPULAR ARCHITECTURES IN ANDROID
 MVP
 MVVM
 MVI
 Clean Architecture
 VIPER
CLEAN ARCHITECTURE
ARCHITECTURE GOALS
 Independence from Framework
 Testable
 Independent of UI
 Independent of Database
 Independent of any external agents (Security, scheduling,
etc)
CLEAN ARCHITECTURE
OBJECT ORIENTED DESIGN GOALS
 S - Single Responsibility Principle
 O - Open/Closed Principle
 L - Liskov Substitution Principle
 I - Interface Segregation Principle
 D - Dependency Inversion Principle
CLEAN ARCHITECTURE
DEPENDENCY INVERSION PRINCIPLE
 High-level modules should not depend on low-level
modules. Both should depend on abstractions.
 Abstractions should not depend on details. Details should
depend on abstractions.
CLEAN ARCHITECTURE
CLEAN ARCHITECTURE
CLEAN ARCHITECTURE
 Introduced by Robert C. Martin (AKA Uncle Bob)
 Inspired by various other architectures like Hexagonal
Architecture, Onion Architecture, etc.
 Readings:
 https://8thlight.com/blog/uncle-bob/2012/08/13/the-
clean-architecture.html
 https://8thlight.com/blog/uncle-bob/2011/11/22/Clean-
Architecture.html
CLEAN ARCHITECTURE
THE DEPENDENCY RULE
 The outer circles are mechanisms. The inner circles are
policies.
 This rule says that source code dependencies can only
point inwards.
 How? Dependency Injection!
CLEAN ARCHITECTURE
KEY TERMS
 Entities (Enterprise wide Business Rules or Business
Objects of a Single Application)
 Use Cases (Application Speci鍖c Business Rules)
 Interface Adapters (Presenters, Controllers, Gateways, etc)
 Frameworks and Drivers (Android Framework, Web, etc)
CLEAN ARCHITECTURE
IMPLEMENTATION
 Watch: https://www.youtube.com/watch?v=Nsjsiz2A9mg
FERNANDO CEJAS
CLEAN ARCHITECTURE
FERNANDO CEJAS APPROACH
DATA-DOMAIN-PRESENTER LAYERING
 Further Reading: https://martinfowler.com/bliki/
PresentationDomainDataLayering.html
FERNANDO CEJAS APPROACH
REACTIVE PROGRAMMING WITH RXJAVA
 Great for Asynchronous Programming
 Eliminate Callbacks
 Robust Error Handling
 Handles threading
FERNANDO CEJAS APPROACH
REACTIVE CLEAN ARCHITECTURE APPROACH
ANALYSIS
FERNANDO CEJAS APPROACH
ANALYSIS OF FERNANDO CEJAS APPROACH
SOURCE CODE
 https://github.com/android10/Android-CleanArchitecture
ANALYSIS OF FERNANDO CEJAS APPROACH
DOMAIN-DATA-PRESENTATION AS MODULES
 Advantage:
 Sharing with multiple android projects
 Strict separation of dependencies
 Disadvantage:
 Navigating between code
ANALYSIS OF FERNANDO CEJAS APPROACH
VIOLATION OF CLEAN ARCHITECTURE PRINCIPLE
 UseCase knows about scheduling
 Where should we actually handle scheduling?
 Some ideas from Android Architecture Blueprint from
Google
 UseCase dependent on RxJava
PUTTING LEARNINGS
INTO PRACTICE
PUTTING LEARNINGS INTO PRACTICE
ADVANTAGES
 One level of breakdown for testability
 Easier to implement functionalities like caching, storage, etc.
 Reusable Usecases
 De鍖ning where to add code for speci鍖c functionality
 Multiple projects can share domain/business logic
 Implement different presentation patterns like MVVM, MVI,
etc.
PUTTING LEARNINGS INTO PRACTICE
DRAWBACKS
 Dependent on RxJava
 Boilerplate code
 UseCaseExecutor takes away several RxJava bene鍖ts
 Request and Response Models in UseCase
 Steep learning curve
 Over-Engineering, perhaps?
PUTTING LEARNINGS INTO PRACTICE
MORE EXPLORATIONS
 MVP
 Respository Pattern
 Dependency Injection with Dagger
 Testing
 Consistency in Models
RESOURCES
RESOURCES
FIVE.AGENCY CLEAN ARCHITECTURE BLOG SERIES
 Android Architecture: Part 1  Every new beginning is hard
 Android Architecture: Part 2  Clean Architecture
 Android Architecture: Part 3  Applying clean architecture
on Android
RESOURCES
MVP
 https://medium.com/@cervonefrancesco/model-view-
presenter-android-guidelines-94970b430ddf#.jkyuzqq0z
RESOURCES
THE MODEL AND REPOSITORY PATTERN
 http://hannesdorfmann.com/android/evolution-of-the-
repository-pattern
 http://futurice.com/blog/top-7-tips-for-the-model-in-
android-architectures
RESOURCES
DAGGER
 https://realm.io/news/360andev-mike-nakhimovich-
sword鍖ghting-dagger-dependency-injection-android/
 https://github.com/friendlyrobotnyc/android-boilerplate
TEXT
USE CASE SCHEDULING
 https://medium.com/@yoelglusc/threading-strategies-on-
android-with-clean-architecture-57f6d3714d96#.iev6hjyya
 https://medium.com/@yoelglusc/android-and-clean-
architecture-the-use-case-
interface-8716512f29a1#.x8gmyvody
RESOURCES
A LARGER EXAMPLE
 https://github.com/badoo/Chateau
THANK YOU

More Related Content

Similar to Clean Architecture (20)

PDF
Devops (start walking in the same direction) by ops
Demis Rizzotto
PDF
Halifax DevOps - Meet-up - July.19 2017
Kyle Bassett
PDF
ITB2017 - Day2 Keynote - Box Microservices
Ortus Solutions, Corp
PDF
Application architecture doesn't have to suck
jtregunna
PDF
A Java Developers first Clojure project
Craig Malone
PDF
Securing the container DevOps pipeline by William Henry
DevSecCon
PPTX
Percepticus_ Node.js_Bulgaria_June_2016
Velko Spasov
PDF
Natively clouded Journey
Haggai Philip Zagury
PPTX
Micro service Arthicetcure
Kian Paimani
PDF
AWS Architecture.pdf
Steffan Norberhuis
PDF
Monolith to modular
GaroHussenjian
PDF
Forecast 2014: Cloud-Aware Applications
Open Data Center Alliance
PDF
State Machines and Workflow Nets on your PHP projects
Daniel Abad Cambronero
PPTX
Full stack development best practice and toolset
Reid Lai
PDF
Cloud Expo East 2013: Essential Open Source Software for Building the Open Cloud
Mark Hinkle
PDF
Kotlin & Swift
zezzi Castillo
PDF
[Srijan Wednesday Webinars] How to Build a Cloud Native Platform for Enterpri...
Srijan Technologies
PDF
[muCon2017]DevSecOps: How to Continuously Integrate Security into DevOps
Daniel Oh
PPTX
Designing a Reliable Software Factory for the Cloud
AnkaraCloud
PDF
Framework Agnostic Discovery
KubeAcademy
Devops (start walking in the same direction) by ops
Demis Rizzotto
Halifax DevOps - Meet-up - July.19 2017
Kyle Bassett
ITB2017 - Day2 Keynote - Box Microservices
Ortus Solutions, Corp
Application architecture doesn't have to suck
jtregunna
A Java Developers first Clojure project
Craig Malone
Securing the container DevOps pipeline by William Henry
DevSecCon
Percepticus_ Node.js_Bulgaria_June_2016
Velko Spasov
Natively clouded Journey
Haggai Philip Zagury
Micro service Arthicetcure
Kian Paimani
AWS Architecture.pdf
Steffan Norberhuis
Monolith to modular
GaroHussenjian
Forecast 2014: Cloud-Aware Applications
Open Data Center Alliance
State Machines and Workflow Nets on your PHP projects
Daniel Abad Cambronero
Full stack development best practice and toolset
Reid Lai
Cloud Expo East 2013: Essential Open Source Software for Building the Open Cloud
Mark Hinkle
Kotlin & Swift
zezzi Castillo
[Srijan Wednesday Webinars] How to Build a Cloud Native Platform for Enterpri...
Srijan Technologies
[muCon2017]DevSecOps: How to Continuously Integrate Security into DevOps
Daniel Oh
Designing a Reliable Software Factory for the Cloud
AnkaraCloud
Framework Agnostic Discovery
KubeAcademy

Recently uploaded (20)

PDF
The Next-Gen HMIS Software AI, Blockchain & Cloud for Housing.pdf
Prudence B2B
DOCX
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
PPTX
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
DOCX
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
PDF
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
PDF
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
PDF
Which Hiring Management Tools Offer the Best ROI?
HireME
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
PDF
Best Software Development at Best Prices
softechies7
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
PDF
Azure AI Foundry: The AI app and agent factory
Maxim Salnikov
PPTX
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
PDF
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
PDF
Rewards and Recognition (2).pdf
ethan Talor
PPTX
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
PDF
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
PPTX
Agentforce TDX 2025 Hackathon Achievement
GetOnCRM Solutions
PDF
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
The Next-Gen HMIS Software AI, Blockchain & Cloud for Housing.pdf
Prudence B2B
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
Which Hiring Management Tools Offer the Best ROI?
HireME
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
Best Software Development at Best Prices
softechies7
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
Azure AI Foundry: The AI app and agent factory
Maxim Salnikov
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
Rewards and Recognition (2).pdf
ethan Talor
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
Agentforce TDX 2025 Hackathon Achievement
GetOnCRM Solutions
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
Ad

Clean Architecture