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
190
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
540
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
A Modern Web Designer's Workflow
chriscoyier
693
190k
Rails Girls Zürich Keynote
gr2m
94
13k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Code Reviewing Like a Champion
maltzj
521
39k
Faster Mobile Websites
deanohume
305
30k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
Typedesign – Prime Four
hannesfritz
40
2.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Optimising Largest Contentful Paint
csswizardry
33
3k
Making Projects Easy
brettharned
116
6k
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ίʔυ͔ΒΧδϡΞϧ໘ஊ ͓͓ͪͯ͠Γ·͢