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
810
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
Jetpack ComposeのBottomSheetとの戦い / Fight with BottomSheet of Jetpack Compose
kubode
0
85
Mobile Chapterが目指すところと技術 / Vision and Technology of Mobile Chapter at Wantedly
kubode
0
110
ウォンテッドリーでのKMPワークフロー / KMP workflow at Wantedly
kubode
0
1k
ComposeでのShared Element Transition / Shared Element Transition in Compose
kubode
0
300
K2への完全移行結果 / Results of complete migration to K2
kubode
2
4.2k
Compose Shadow Alternative
kubode
0
250
アイコンをComposeにする / Compose the Icons
kubode
0
440
デザインシステムのCompose実装 / Design system Compose implementation
kubode
0
510
KMMのCI/CD
kubode
3
740
Other Decks in Programming
See All in Programming
最近追加した型の紹介とその振り返り
aki19035vc
0
180
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
Exploring the Gradually Lost Technical Skills in the Cloud Native Era
hwchiu
2
3.9k
DDDを志して3年経ったら「DDDの皮を被ったクリーンアーキテクチャ」になった話【デブサミ2024夏】
texmeijin
1
620
Rust.Nagoya #1
codemountains
0
170
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
Microservices rules (July 2024) : what good looks like
cer
PRO
0
1.6k
ぼっちを避けて楽しむためのアノテコノテ / Various Tips and Tricks to Avoid Loneliness and Have Fun
nrslib
3
1.7k
feature環境をGitHub ActionsとCloudFormationでいい感じに管理する
nealle
2
310
Terraformテスト入門
msato
0
540
なぜ宣言的 UI は壊れにくいのか / Why declarative UI is less fragile
uenitty
29
13k
유연한 Composable 설계
l2hyunwoo
0
380
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
31
4.7k
Ruby is Unlike a Banana
tanoku
96
10k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
16
1.6k
Art, The Web, and Tiny UX
lynnandtonic
291
20k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
52k
Being A Developer After 40
akosma
72
580k
Bash Introduction
62gerente
607
210k
Testing 201, or: Great Expectations
jmmastey
33
6.9k
Rails Girls Zürich Keynote
gr2m
93
13k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.3k
The Cult of Friendly URLs
andyhume
75
5.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
121
18k
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!