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
Joe Birch
March 17, 2017
Programming
720
10
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Getting Clean, Keeping Lean
Joe Birch
March 17, 2017
More Decks by Joe Birch
See All by Joe Birch
Learning to play guitar with Actions on Google
hitherejoe
1
130
Making Change as an Ally
hitherejoe
1
520
Tensorflow for Android Developers
hitherejoe
3
290
Learning to play the guitar with Actions on Google
hitherejoe
0
170
For Optimists, our UI is pretty Pessimistic
hitherejoe
4
3k
Android Things: Building for the IoT
hitherejoe
2
210
Android TV: Building Apps with Google’s Leanback Library
hitherejoe
1
1.1k
Building Beautiful Apps with the Design Support Library
hitherejoe
3
280
Other Decks in Programming
See All in Programming
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
570
Claude Team Plan導入・ガイド
tk3fftk
0
250
Foundation Models frameworkで画像分析
ryodeveloper
1
510
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.2k
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
18k
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
1.1k
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
200
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
550
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.8k
仕様駆動開発の消費期限
watany
7
1.7k
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
650
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
650
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Utilizing Notion as your number one productivity tool
mfonobong
4
500
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
Designing Experiences People Love
moore
143
24k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Optimizing for Happiness
mojombo
378
71k
The Language of Interfaces
destraynor
162
27k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
480
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
420
Prompt Engineering for Job Search
mfonobong
0
390
How STYLIGHT went responsive
nonsquared
100
6.2k
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)