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
Practical Modularisation for Android Developers
Search
Jordan Terry
April 21, 2022
Programming
0
3
Practical Modularisation for Android Developers
How can you use Gradle and an extremely opinionated module structure to reduce your build times?
Jordan Terry
April 21, 2022
Tweet
Share
More Decks by Jordan Terry
See All by Jordan Terry
Resuable Modules - Its as easy as ABI
jordan_terry
0
33
Other Decks in Programming
See All in Programming
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
Click-free releases & the making of a CLI app
oheyadam
2
110
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
520
役立つログに取り組もう
irof
28
9.6k
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
C++でシェーダを書く
fadis
6
4.1k
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Gamification - CAS2011
davidbonilla
80
5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
For a Future-Friendly Web
brad_frost
175
9.4k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
860
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
A designer walks into a library…
pauljervisheath
203
24k
Code Review Best Practice
trishagee
64
17k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Transcript
Practical modularisation for Android developers Jordan Terry 1
Agenda • Introduction • What is modularisation? • What is
your codebase? • Cohesion, Coupling & Gradle • Build times • Reusability • Defining a strategy • Questions? 2
3 Introduction 🇹 Then Now 2015 2018 2021 @JordNullable
What is modularisation? 4
5 What is modularisation? Large system Modules
6
7 Android modularisation Large System Modules Codebase Gradle Modules
Talking about modularisation 8
The benefits of modularisation 9 Build Times Reusability
What is your codebase? 10 • Define a way to
measure modularisation • Apply that to your codebase
11 Monolithic Modular What is your codebase? You are somewhere
here…
12 Monolithic Modular What is your codebase? = code base
with a module that takes more time to compile than other modules = code base with no modules that take more time to compile than the sum of other modules
What is your codebase? 13 Monolithic Modular
14 Monolithic Very Modular What is your codebase? Modular
15
Cohesion, Coupling & Gradle 16
High Cohesion Low Cohesion Cohesion 17 Low Cohesion High Cohesion
High Coupling Low Coupling Coupling 18 Low Coupling High Coupling
Gradle 19 • Module definition • Connecting Modules • Incremental
Compilation
20 import ':app' import ':login' import ':profile' import ':networking' import
':okhttp' settings.gradle.kts app/ -> login/ -> src/ -> build.gradle.kts -> profile/ -> src/ -> build.gradle.kts -> networking/ -> src/ -> build.gradle.kts -> okhttp/ -> src/ -> build.gradle.kts -> settings.gradle.kts app/ -> login/ -> src/ -> build.gradle.kts -> profile/ -> src/ -> build.gradle.kts -> networking/ -> src/ -> build.gradle.kts -> okhttp/ -> src/ -> build.gradle.kts -> settings.gradle.kts app/ -> login/ -> src/ -> build.gradle.kts -> profile/ -> src/ -> build.gradle.kts -> networking/ -> src/ -> build.gradle.kts -> okhttp/ -> src/ -> build.gradle.kts -> settings.gradle.kts app/ -> login/ -> src/ -> build.gradle.kts -> profile/ -> src/ -> build.gradle.kts -> networking/ -> src/ -> build.gradle.kts -> okhttp/ -> src/ -> build.gradle.kts -> settings.gradle.kts build.gradle.kts plugins { id("kotlin-android") } android { ... } dependencies { ... } Defining Modules
21 :networking :login :profile :okhttp :app Defining modules
dependencies { implementation project(":login") implementation project(":profile") } 22 app/build.gradle.kts Connecting
modules
23 :networking :login :profile :okhttp :app Connecting Modules
:profile :profile 24 :profile Incremental compilation
:login :profile :profile :login :networking :networking 25 :okhttp :app Incremental
compilation
The benefits of modularisation 26 Build Times Reusability
Incremental Build times 27 • How important are build times?
• When incremental build times go wrong • Some tips on cohesion
XKCD 303 - https://xkcd.com/303/ 28 Build Times
@vRallev on Twitter - https://mobile.twitter.com/vRallev/status/1485430862850125824 29 Build Times
@softwarejameson on Twitter - https://twitter.com/softwarejameson/status/1455971162060697613?lang=en 30 Build Times
Build times 600 engineers * $1.42/minutes * 42 builds/week *
44 work weeks/year = $1,600,000/year 31 Gradle vs Maven: Performance Comparison - https://gradle.org/gradle-vs-maven-performance/ Money Saved Equation
:timelines :profile :login :network models 32 Build times - comparing
structures :app :timelines :login :profile :networking :networking :network models
:timelines :login :login models :profile models :timeline models :profile :networking
33 Build times - comparing structures :app :timelines :login :profile :networking :login models :profile models :timeline models :json
Reusability 34 • What are reusable components • Reusable libraries
• Reusable modules
Reusability 35 OkHttp Play Billing Toast API
:timelines :profile :okhttp-4 :login Reusability - Third Parties 36 :timelines
:login :profile :okhttp-3 :okhttp-4 :networking :networking :okhttp-3
:navigation :navigation jetpack :navigation compose :login :timelines :timelines :login :profile
:profile Reusability - APIs & Implementations 37 :navigation :api :navigation: impl compose :navigation: impl jetpack :navigation :impl
A modularisation strategy 38 • Training • Discipline ◦ Cohesion
& Coupling
Coming up with a plan 39 :foundation :feature :feature :feature
:feature High Cohesion Low Coupling
Where to find me? 40 • @JordNullable
Any questions? 41