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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
530
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
200
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.5k
AI時代、1年目エンジニアの悩み
jin4
1
150
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
150
30万人の同時アクセスに耐えたい!新サービスの盤石なリリースを支える負荷試験 / SRE Kaigi 2026
genda
1
140
toCプロダクトにおけるAI機能開発のしくじりと学び / ai-product-failures-and-learnings
rince
6
5.4k
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
110
クレジットカード決済基盤を支えるSRE - 厳格な監査とSRE運用の両立 (SRE Kaigi 2026)
capytan
6
1.9k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
13k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
510
Featured
See All Featured
Balancing Empowerment & Direction
lara
5
880
Crafting Experiences
bethany
1
46
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
[SF Ruby Conf 2025] Rails X
palkan
0
740
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
120
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
New Earth Scene 8
popppiees
1
1.5k
The Language of Interfaces
destraynor
162
26k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Believing is Seeing
oripsolob
1
50
Paper Plane (Part 1)
katiecoart
PRO
0
3.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
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