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
130
Clean Architecture & Error Handling
Ahtsham Abbasi
October 24, 2022
Tweet
Share
Other Decks in Technology
See All in Technology
〜『世界中の家族のこころのインフラ』を目指して”次の10年”へ〜 SREが導いたグローバルサービスの信頼性向上戦略とその舞台裏 / Towards the Next Decade: Enhancing Global Service Reliability
kohbis
2
550
いつの間にか入れ替わってる!?新しいAWS Security Hubとは?
cmusudakeisuke
0
140
[SRE NEXT] ARR150億円_エンジニア140名_27チーム_17プロダクトから始めるSLO.pdf
satos
2
880
TableauLangchainとは何か?
cielo1985
1
120
60以上のプロダクトを持つ組織における開発者体験向上への取り組み - チームAPIとBackstageで構築する組織の可視化基盤 - / sre next 2025 Efforts to Improve Developer Experience in an Organization with Over 60 Products
vtryo
2
520
United Airlines Customer Service– Call 1-833-341-3142 Now!
airhelp
0
170
AWS CDKの仕組み / how-aws-cdk-works
gotok365
9
420
ABEMAの本番環境負荷試験への挑戦
mk2taiga
5
370
CDKTFについてざっくり理解する!!~CloudFormationからCDKTFへ変換するツールも作ってみた~
masakiokuda
1
180
How to Quickly Call American Airlines®️ U.S. Customer Care : Full Guide
flyaahelpguide
0
180
開発生産性を組織全体の「生産性」へ! 部門間連携の壁を越える実践的ステップ
sudo5in5k
3
7.6k
TLSから見るSREの未来
atpons
2
110
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
The Pragmatic Product Professional
lauravandoore
35
6.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Speed Design
sergeychernyshev
32
1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Code Review Best Practice
trishagee
69
19k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Navigating Team Friction
lara
187
15k
For a Future-Friendly Web
brad_frost
179
9.8k
Statistics for Hackers
jakevdp
799
220k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
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 ahtabbasi@gmail.com https://www.linkedin.com/in/ahtabbasi/ mobiquity