Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Clean Architecture & Error Handling
Search
Ahtsham Abbasi
October 24, 2022
Technology
0
140
Clean Architecture & Error Handling
Ahtsham Abbasi
October 24, 2022
Tweet
Share
Other Decks in Technology
See All in Technology
CDKで始めるTypeScript開発のススメ
tsukuboshi
1
480
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
3
1.5k
AzureでのIaC - Bicep? Terraform? それ早く言ってよ会議
torumakabe
1
580
Amazon Bedrock Knowledge Basesチャンキング解説!
aoinoguchi
0
150
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
310
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
650
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
68k
レガシー共有バッチ基盤への挑戦 - SREドリブンなリアーキテクチャリングの取り組み
tatsukoni
0
220
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
160
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
240
【Ubie】AIを活用した広告アセット「爆速」生成事例 | AI_Ops_Community_Vol.2
yoshiki_0316
1
110
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
1
370
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
180
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
83
Paper Plane (Part 1)
katiecoart
PRO
0
4.3k
Building the Perfect Custom Keyboard
takai
2
690
Navigating Weather and Climate Data
rabernat
0
110
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
117
110k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
120
GraphQLとの向き合い方2022年版
quramy
50
14k
The Spectacular Lies of Maps
axbom
PRO
1
520
Faster Mobile Websites
deanohume
310
31k
Transcript
Clean Architecture & Error Handling Ahtsham Abbasi Senior Android Developer
@ Mobiquity Consultant @ Rabobank mobiquity
Agenda 1. Clean Architecture 2. Domain Layer 3. Conclusion
#1 Clean Architecture What’s all the fuss about?
None
Why Architecture?
Why Clean Architecture? • Decouples the external components
Why Clean Architecture? • Decouples the external components • Works
with other architectures like MVP, MVC, MVVM
Why Clean Architecture? • Decouples the external components • Works
with other architectures like MVP, MVC, MVVM • Framework independent
What is Clean Architecture?
What is Clean Architecture? Clean code
What is Clean Architecture? Clean code
What is Clean Architecture? Clean code Onion arch. + Hexagonal
arch.
What is Clean Architecture?
Flow of Control
Flow of Control Use Case Controller DB IoC
Number of layers
Layers Entities Use Cases Repositories View Models User Interface Database
Rem ote API
Frontend app • Outer most circle • Notifications code •
Cookies • Displaying content
Backend app • Outer most circle • Database code •
Auth library • 3rd party services
Models Each layer must have its own models.
Dependency Injection Koin, Guice, Spring
#2 Domain Layer Implementation and error handling
Domain Layer
Components of Domain Layer • Use cases
Components of Domain Layer • Use cases • Models
Components of Domain Layer • Use cases • Models •
Interfaces
Use Cases
None
None
None
None
None
Structuring a Use Case • Scope
Structuring a Use Case • Scope • Structure
Structuring a Use Case • Scope • Structure • Inputs
/ Outputs
Outputs • Requirement • Exhaustive output • Easy to learn
• Easy to scale
Outputs • Requirement • Exhaustive output • Easy to learn
• Easy to scale • Different options considered • Kotlin Try • Monadic outputs • Arrow-Kt • Sealed classes
Example
Invocation
Pitfalls to avoid
Pifalls to avoid • Returning nulls
Pifalls to avoid • Returning nulls • Wrapping non-exhaustible data
in outputs
Pifalls to avoid • Returning nulls • Wrapping non-exhaustible data
in outputs • Callbacks
Pifalls to avoid • Returning nulls • Wrapping non-exhaustible data
in outputs • Callbacks • Exceptions
Pifalls to avoid • Returning nulls • Wrapping non-exhaustible data
in outputs • Callbacks • Exceptions • Base classes
Other Layers Entities Use Cases Repositories View Models User Interface
Database Rem ote API • Separate models • Aggregate outputs • Avoid exceptions
#3 Conclusions Learnings so far
Is it a good architecture for me?
It is for you, if you want to.. • Manage
complex and scaling business requirements
It is for you, if you want to.. • Manage
complex and scaling business requirements • Decouple the external components
It is for you, if you want to.. • Manage
complex and scaling business requirements • Decouple the external components • Share business logic across platforms
It is for you, if you want to.. • Manage
complex and scaling business requirements • Decouple the external components • Share business logic across platforms • Increase testability
It is for you, if you want to.. • Manage
complex and scaling business requirements • Decouple the external components • Share business logic across platforms • Increase testability • Have a framework independent architecture
Drawbacks
Drawbacks • Code duplication • Boilerplate code • Learning curve
• Not ideal for smaller projects
Final thoughts
Resources • Clean Architecture Book by Robert C. Martin •
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html • https://elizarov.medium.com/kotlin-and-exceptions-8062f589d07 • https://pusher.com/tutorials/clean-architecture-introduction/
Thank you! Ahtsham Abbasi
[email protected]
https://www.linkedin.com/in/ahtabbasi/ mobiquity