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
Compose駆動開発のためのマルチモジュール化
Search
kobayashi_kento
October 26, 2023
0
180
Compose駆動開発のためのマルチモジュール化
2023年10月26日(木)開催のpixiv App Nightで発表した資料です。
kobayashi_kento
October 26, 2023
Tweet
Share
More Decks by kobayashi_kento
See All by kobayashi_kento
Kotlinの好きなところ
kobaken0029
0
480
DataStoreを導入してみた
kobaken0029
1
280
Epoxyを用いたレイアウト構築術
kobaken0029
1
210
Androidエンジニアが1週間でiOSアプリ開発を学び、1ヶ月で大規模アプリ開発にJOINした話
kobaken0029
0
3k
Modern REST Communicate for Android
kobaken0029
0
1.5k
AndroidでモダンREST通信してみたった
kobaken0029
0
250
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
49
11k
The Pragmatic Product Professional
lauravandoore
32
6.3k
A better future with KSS
kneath
238
17k
Writing Fast Ruby
sferik
628
61k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
A Philosophy of Restraint
colly
203
16k
GitHub's CSS Performance
jonrohan
1030
460k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Visualization
eitanlees
146
15k
Building an army of robots
kneath
302
44k
Gamification - CAS2011
davidbonilla
80
5.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Transcript
@kobaken Composeۦಈ։ൃͷͨΊͷ ϚϧνϞδϡʔϧԽ
ࣗݾհ • kobakenʢ@koba_dog_ʣ • ίϛοΫࣄۀ෦pixivίϛοΫ෦։ൃνʔϜ • AndroidΞϓϦΛ୲ • ࠷ۙRailsॻ͍ͯ·͢
None
pixivίϛοΫΞϓϦͷ։ൃঢ়گʹ͍ͭͯ • 20152݄ʹAndroidΞϓϦ͕ϦϦʔε • جຊతʹappϞδϡʔϧͰͯ͢ͷػೳ͕࣮͞Ε͍ͯͨ • ՝ۚपΓͷॲཧ͕ผϞδϡʔϧͰΓ͚ΒΕ͍ͯͨఔ • 202310݄ݱࡏɺAndroidΞϓϦΤϯδχΞ3ਓମ੍
ϚϧνϞδϡʔϧԽͷϞνϕʔγϣϯ • pixivίϛοΫΞϓϦͰJetpack ComposeΛಋೖ͢Δ͜ͱʹ • ࣮ࡍʹಋೖͯ͠ΈΔͱϓϨϏϡʔ͕͍ • ΄΅ͯ͢ͷґଘ͕ؔappϞδϡʔϧͰ͍݁ͯ͠ΔͨΊ • Composeͷ։ൃମݧΛվળ͍ͨ͠
ϚϧνϞδϡʔϧԽΛਐΊΔલʹ • ϚϧνϞδϡʔϧԽ੍ͱͯ͠॥ࢀরNG͕͋ΔͷͰܭըతʹਐΊͯ ͍͘ඞཁ͕͋Δ • νʔϜ։ൃͷ߹ɺํڞ༗ͷͨΊʹਤʹى͍ͯ͘͜͠
pixivίϛοΫͰͷϞδϡʔϧઃܭ • app • feature • core
appϞδϡʔϧ pixivίϛοΫͰͷϞδϡʔϧઃܭ ΞϓϦશମͷΤϯτϦϙΠϯτͱͳ ΔϞδϡʔϧɻ ɾApplicationΫϥεΤϯτϦͱͳ ΔActivity͕ஔ͞ΕΔɻ ɾϏϧυόϦΞϯτͷΓସ͑୲ ɻ ɾҠߦظؒதશͯͷϞδϡʔϧͷ ґଘؔΛ࣋ͪɺDI͜͜Ͱߦ͏ɻ
featureϞδϡʔϧ pixivίϛοΫͰͷϞδϡʔϧઃܭ ֤ػೳͷ࣮͕ஔ͞ΕΔϞδϡʔ ϧɻ :feature:${ػೳ໊}:presentation ActivityViewModelΛஔɻ :feature:${ػೳ໊}:compose ࠓճͷ؊ɻػೳ༝དྷͷCompose࣮ Λஔɻޙड़͢Δcommonuiͱ ͍ͬͨ࠷খݶͷґଘؔͷΈɻ
coreϞδϡʔϧ pixivίϛοΫͰͷϞδϡʔϧઃܭ ModelutilܥͳͲڞ௨ϩδοΫ͕ ஔ͞ΕΔϞδϡʔϧɻ :core:data:model σʔλܕΛදݱ͢ΔModelΛஔɻ :core:data:repository RepositoryΛஔɻσʔλͷऔಘߋ ৽ͳͲɻ࣮ࡍʹ௨৴ͨ͠ΓɺDBͳ ͲϩʔΧϧϑΝΠϧʹΞΫηε͢Δ
ॲཧܥޙड़͢Δinfraʹஔ͢Δɻ
coreϞδϡʔϧ pixivίϛοΫͰͷϞδϡʔϧઃܭ ModelutilܥͳͲڞ௨ϩδοΫ͕ ஔ͞ΕΔϞδϡʔϧɻ :core:infra:local DBDataStoreɺϑΝΠϧૢ࡞ܥͳ ͲΛஔɻ :core:infra:remote APIΫϥΠΞϯτResponseͷܕఆ ٛͳͲΛஔɻ
coreϞδϡʔϧ pixivίϛοΫͰͷϞδϡʔϧઃܭ ModelutilܥͳͲڞ௨ϩδοΫ͕ ஔ͞ΕΔϞδϡʔϧɻ :core:network ωοτϫʔΫଓʹؔ͢Δॲཧ൚ ༻ResponseͳͲΛஔɻ :core:analytics FirebaseͷΠϕϯτϩάૹ৴ϩ δοΫΛஔɻ
coreϞδϡʔϧ pixivίϛοΫͰͷϞδϡʔϧઃܭ ModelutilܥͳͲڞ௨ϩδοΫ͕ ஔ͞ΕΔϞδϡʔϧɻ :core:ui ComposeͷThemeΧϥʔύϨο τɺ൚༻ComposableΛஔɻ :core:common ଞͷcoreʹؔ͢ΔϞδϡʔϧʹଐ͞ ͳ͍൚༻ॲཧܥΛஔɻ
None
࣮ߦ • খ࢝͘͞Ί͍ͯ͘ • ຊདྷͷతͰ͋ΔʮCompose։ൃମݧͷվળʯΛҙࣝ • ·ͣ:feature:${ػೳ໊}:compose͔Βணख • appϞδϡʔϧʹ͋ΔModelʹґଘ͠ͳ͍Α͏ʹcomposeϞδϡʔϧ ͰUIStateΛఆٛ
࣮ྫ :appͰࢀর͍ͯͨ͠Model ͱ૬ޓมͰ͖ΔUIͷͨΊ ͷܕΛ:composeͰ࠶ఆٛ
࣮ྫ :featureʹViewModelͷ interfaceΛઃ͚ͯରԠ͢Δ ͷOK
࣮ࡍʹҠߦͯ͠Έͨ݁Ռ…
ͱ͋ΔҰը໘ͷ composeϞδϡʔϧͷҠߦલޙͷϓϨϏϡʔʹ͔͔Δ࣌ؒ
ࠓޙͷల • coreϞδϡʔϧͷׂ • ModelRepositoryɺͦͷଞڞ௨ॲཧͷҠߦ • ֤ը໘ΛfeatureϞδϡʔϧׂ • ActivityViewModel࣮Λ:feature:presentationʹҠߦ͢Δ
·ͱΊ • ComposeΛϞδϡʔϧׂͨ͜͠ͱͰϓϨϏϡʔΛվળͨ͠ • Compose͚ͩͷׂͳΒҊ֎ؾܰʹߦಈʹҠͤΔ • ϚϧνϞδϡʔϧ͕ఆ͞Εͯͳ͍தنҎ্ͷϓϩδΣΫτͰͷϚϧ νϞδϡʔϧԽେม • ϓϩδΣΫτنʹΑΔ͕ɺࣄલͷܭը͕େࣄ
• ҰؾʹΖ͏ͱͤͣʹͪΐͬͱͣͭਐΊΔͷ͕٢
AndroidΞϓϦΛ Ұॹʹ։ൃͯ͘͠ΕΔ ਓΛืू͍ͯ͠·͢ʂ ΧδϡΞϧ໘ஊͷ͓Βͤ ϚϧνϞδϡʔϧComposeͳͲ ͳΜͰ͓ؾܰʹ ԼهQRίʔυ͔ΒΧδϡΞϧ໘ஊ ͓͓ͪͯ͠Γ·͢