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
Data Bindingの移行を楽にする / Easier migration of Data Binding
Search
Masatoshi Kubode
December 19, 2023
Programming
0
450
Data Bindingの移行を楽にする / Easier migration of Data Binding
LT at
https://sansan.connpass.com/event/303229/
Masatoshi Kubode
December 19, 2023
Tweet
Share
More Decks by Masatoshi Kubode
See All by Masatoshi Kubode
ComposeでのShared Element Transition / Shared Element Transition in Compose
kubode
0
170
K2への完全移行結果 / Results of complete migration to K2
kubode
1
2k
Compose Shadow Alternative
kubode
0
160
アイコンをComposeにする / Compose the Icons
kubode
0
360
デザインシステムのCompose実装 / Design system Compose implementation
kubode
0
440
KMMのCI/CD
kubode
3
690
WantedlyでのCompose導入 / Introducing Jetpack Compose at Wantedly
kubode
1
380
DroidKaigi/conference-app-2022へのContributionが楽しかった話 / Contributing DroidKaigi app was fun!
kubode
0
940
継続的な依存性のアップデートにより得られたこと / What we have learned from continuous dependency updates
kubode
0
390
Other Decks in Programming
See All in Programming
Anthropic Cookbook のおすすめレシピ
schroneko
7
1k
"config" ってなんだ? / What is "config"?
okashoi
0
240
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
390
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
110
Ruby Function Composition
bkuhlmann
1
330
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
430
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
1
270
#phpcon_odawara オープン・クローズドなテストフィクスチャを求めて / open closed test fixtures
77web
3
230
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
320
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
910
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
280
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
220
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
25
2.3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
2
1.3k
How to train your dragon (web standard)
notwaldorf
73
5.2k
Scaling GitHub
holman
457
140k
Designing Experiences People Love
moore
136
23k
What’s in a name? Adding method to the madness
productmarketing
PRO
16
2.6k
Rails Girls Zürich Keynote
gr2m
91
13k
GraphQLとの向き合い方2022年版
quramy
32
12k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
260
12k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Transcript
© 2023 Wantedly, Inc. Data Bindingの 移行を楽にする モバイル勉強会#12 2023/12/19 久保出雅俊
© 2023 Wantedly, Inc. wantedly.com/id/kubode © 2023 Wantedly, Inc. X:
@swiz_ard GitHub: @kubode
© 2023 Wantedly, Inc. Data Binding移行終わった人 🙋
© 2023 Wantedly, Inc. なお弊社 😇
© 2023 Wantedly, Inc. 移行を楽にする話
© 2023 Wantedly, Inc. はじめに
© 2023 Wantedly, Inc. Data Bindingとは • Android公式のライブラリ • XMLにデータのバインディング処理を記述できる
• 2015年リリース ◦ 導入事例は多い認識 • 現在はメンテナンスモード ◦ Composeへの移行を推奨
© 2023 Wantedly, Inc. なぜ移行する? • 公式にKSPに移行しない表明 • KAPT依存しつづける ◦
ビルド時間に影響 ◦ K2 Compilerに移行できない原因(K2側で解消しつつある)
© 2023 Wantedly, Inc. 移行先 • Compose ◦ 公式が推奨する移行先 ◦
UI作り直しになるため移行コストが高い • View Binding ◦ Data Bindingから移行しやすいインターフェース ◦ バインディング処理の再実装は必要
© 2023 Wantedly, Inc. View Binding • Data Bindingと同じ点 ◦
生成されるクラス名とパッケージ名 ◦ findViewById/requireViewById不要 • 異なる点 ◦ バインディング処理はXMLじゃなくてJava/Kotlinで ◦ BindingAdapterなどもなし
© 2023 Wantedly, Inc. View Bindingへの移行
© 2023 Wantedly, Inc. 手作業での移行 • まずは1つのXMLを移行してみた ◦ バインディングしてる箇所を探す( android:text=”@{state.text}”)
◦ Kotlinコードで再実装 • バインディング周りがとにかくつらい ◦ バインディング変数をGETする箇所もある ◦ 1つのバインディング変数が複数箇所で使われていると脳内メモリを圧迫 ◦ 複雑なバインディング式 ◦ Reflection ◦ nullabilityの扱いの違い(@{state.text} -> state?.text.orEmpty())
© 2023 Wantedly, Inc. 手作業を減らさないと無理
© 2023 Wantedly, Inc. ヘルパープラグインの作成 • ある程度自動でやってくれるプラグインを作成 • 目的は、移行を簡単にすること ◦
コードの書き換えを最小限に ◦ Data BindingとView Bindingのインターフェースの近似を活かす ◦ 実行時パフォーマンスは妥協
© 2023 Wantedly, Inc. 流れ
© 2023 Wantedly, Inc. プラグイン実行 • プラグインを対象モジュールに適用 ◦ apply(MigrateDataBindingToViewBindingPlugin) •
タスク実行 ◦ ./gradlew :mymodule:migrateDataBindingToViewBinding
© 2023 Wantedly, Inc. XMLをピュアに • ある程度自動でやってくれるプラグインを作成 ◦ XMLをピュアなレイアウトXMLに書き換え ◦
Bindingクラスの拡張 ▪ バインディング変数 ▪ TODOリスト付きのバインド処理関数
© 2023 Wantedly, Inc. バインディング拡張の生成 このTODOを解消すればOK! バインディング変数だったものを拡 張プロパティに
© 2023 Wantedly, Inc. あとは手作業
© 2023 Wantedly, Inc. あとは手作業 大抵は、拡張プロパティを importするだけでよい
© 2023 Wantedly, Inc. まとめ
© 2023 Wantedly, Inc. まとめ • 苦行がかなり改善された ◦ バインディング実装やレビューはつらいまま •
属人性が減り再現性のある作業に変わった • Data Binding移行を考えてる人は是非お試しを 1ヶ月位
© 2023 Wantedly, Inc. We are hiring!