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
Getting Clean, Keeping Lean
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Joe Birch
March 17, 2017
Programming
10
700
Getting Clean, Keeping Lean
Joe Birch
March 17, 2017
Tweet
Share
More Decks by Joe Birch
See All by Joe Birch
Learning to play guitar with Actions on Google
hitherejoe
1
100
Making Change as an Ally
hitherejoe
1
490
Tensorflow for Android Developers
hitherejoe
3
280
Learning to play the guitar with Actions on Google
hitherejoe
0
150
For Optimists, our UI is pretty Pessimistic
hitherejoe
4
2.9k
Android Things: Building for the IoT
hitherejoe
2
190
Android TV: Building Apps with Google’s Leanback Library
hitherejoe
1
1.1k
Building Beautiful Apps with the Design Support Library
hitherejoe
3
260
Other Decks in Programming
See All in Programming
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
Apache Iceberg V3 and migration to V3
tomtanaka
0
140
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
18
6.2k
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
590
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
510
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
0
870
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
110
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
150
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
2.4k
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
110
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Ethics towards AI in product and experience design
skipperchong
2
190
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
We Are The Robots
honzajavorek
0
160
WENDY [Excerpt]
tessaabrams
9
36k
Rails Girls Zürich Keynote
gr2m
96
14k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
Embracing the Ebb and Flow
colly
88
5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
100
Into the Great Unknown - MozCon
thekraken
40
2.2k
Testing 201, or: Great Expectations
jmmastey
46
8k
Transcript
Getting clean. Keeping lean.
@hitherejoe hitherejoe joebirch.co Joe Birch - Android Engineer @ Buffer
@buffer buffer.com
Greenfield projects
None
- High-level of technical debt - Extremely tightly coupled concepts
- No unit or UI tests - Difficult to know what is going on and where No longer lean
- YOU know what is what - YOU know where
class X is - YOU know where logic for Y is - But what about along the line… No longer lean (for now) (for now) (for now)
25 50 75 100 Output Debt
25 50 75 100 Output Debt
For the sake of yours and future developers sanity -
have empathy. Be mindful of the consequences and think before you craft.
Buffer for Android
None
None
None
- Lack of architecture - Bloated activities with multiple responsibilities
- Difficult to test - Difficult to extend and maintain - Duplication of concepts == no reuse
Moving to MVP - Fear of changing too much -
Helped separate presentation logic - DataManagers to house data operations - Increased test coverage
None
None
Not enough. - Bloated DataManager classes - Future changes, offline
- where? - Presentation linked to specific data source - No clear line between responsibilites - Buffer is a big app. Data types, features, sources
Architecture “The art of planning, designing and constructing buildings”
Architecture “The art of planning, designing and constructing buildings concepts”
None
None
None
None
None
Think outside of your team.
Clean Architecture
None
Separation of Concerns
- Layers are independent of frameworks - Code becomes more
testable - Inner layers independant of UI - Inner layers independant of external parties Separation of Concerns - Bugs more isolated
None
Layer Models - Each layer has own Model classes -
Removes dependancy on external models - Easily map with Mapper classes
ModelA Mapper Model Mapper Model
Enterprise Business Rules - Application Business Objects (Entities) - Unaffected
by operational change - Can create before touching any UI
public class TournamentModel { public String id; public String
name; @SerializedName("full_name") public String status; @SerializedName("date_start") public String dateStart; @SerializedName("date_end") public String dateEnd; public int size; }
Application Business Rules - Application specific business rules - Uses
Cases - Affected by operational change - Isolated from external concerns
public class GetSchedules extends UseCase<ProfileSchedules> { private final SchedulesRepository
schedulesRepository; @Inject public GetSchedules(SchedulesRepository schedulesRepository) { this.schedulesRepository = schedulesRepository; } @Override public Single<ProfileSchedules> buildUseCaseObservable() { return schedulesRepository.getSchedules(); } }
None
Use Case Interface Interface Impl Activity Application Business Rules Interface
Adapters
Interface Adapters - Contains MVP architecture of our app -
Presenters contain ‘callbacks’ - Views define contract for implementation - Mapper converts data from external form
public class UpdatesPresenter extends BasePresenter<UpdatesMvpView> implements SingleObserver<List<Update>> { @Override public
void onSubscribe(Disposable d) { … } @Override public void onSuccess(List<Match> matches) { … } @Override public void onError(Throwable e) { … } }
Presenter Interface Interface Impl Activity Interface Adapters Frameworks & Drivers
Frameworks & Drivers - UI components (Activities, Fragments) - Networking
actions (Retrofit) - Storage (Cache & DB) - Repository Pattern for interacting with these
Repository Interface Repository Impl DataStore Interface DataStore Impl DataStore Impl
DataStore Factory
None
Layer Boundaries - Communication via abstractions (interfaces) - No direct
name references in inner layers - Instead, inner layer provides this interface - aka, The Dependancy Inversion Principle
Not limited to these layers Layer 1 Layer 2 Layer
3 Layer 4
Not limited to these layers Layer 1 Layer 2 Layer
3
Not limited to these layers Layer 1 Layer 2 Layer
3 Layer 4 Layer 5 Layer 6
Test Coverage
None
Learnings
Advantages. - High percentage of code coverage - Incredibly easy
to navigate package structure - Easier to maintain - Allows us to move faster - Focused classes and test classes
- Seperation of concerns - Define, Test, Stabilise before UI
- Futureproof implementations - Clear discipline, good practice - and more…
Disadvantages - Adds initial overhead - Takes time to get
used to - Can feel overkill for some tasks - Difficult to make decisions - Conversion of models between layers
Winston Enterprise Business Rules Application Business Rules Interface Adapters Mobile
UI TV UI Wear UI Frameworks & Drivers
Winston Enterprise Business Rules Application Business Rules Interface Adapters Mobile
UI TV UI Wear UI Frameworks & Drivers @hitherejoe hitherejoe joebirch.co
Resources https://overflow.buffer.com/2016/12/22/rebuild- android-composer/ https://github.com/googlesamples/android- architecture Clean Architecture: A Craftsman's Guide
to Software Structure and Design (Robert C. Martin)