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...
Search
Masatoshi Kubode
December 19, 2023
Programming
0
1.9k
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
Firebase Dynamic Linksの代替手段を自作する / Create your own Firebase Dynamic Links alternative
kubode
0
170
技術を根付かせる / How to make technology take root
kubode
1
300
WantedlyでのKotlin Multiplatformの導入と課題 / Kotlin Multiplatform Implementation and Challenges at Wantedly
kubode
0
370
Google Play Consoleデベロッパー アカウントの確認 / Verifying your Play Console developer account
kubode
1
1.1k
Make your Android app into Multiplatform app
kubode
0
120
ウォンテッドリーにおけるモバイルアプリ開発 / iOSDC Japan 2024 Sponsor Session
kubode
1
900
Jetpack ComposeのBottomSheetとの戦い / Fight with BottomSheet of Jetpack Compose
kubode
0
650
Mobile Chapterが目指すところと技術 / Vision and Technology of Mobile Chapter at Wantedly
kubode
0
330
ウォンテッドリーでのKMPワークフロー / KMP workflow at Wantedly
kubode
0
1.7k
Other Decks in Programming
See All in Programming
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
770
データベースエンジニアの仕事を楽にする。PgAssistantの紹介
nnaka2992
9
4.1k
生産性アップのためのAI個人活用
kunoyasu
0
480
snacks.nvim内のセットアップ不要なプラグインを紹介 / introduce_snacks_nvim
uhooi
0
320
‘무차별 LGTM~👍’만 외치던 우리가 ‘고봉밥 코드 리뷰’를?
hannah0731
0
520
보일러플레이트 코드가 진짜 나쁜 건가요?
gaeun5744
0
370
イベントソーシングによってインピーダンスミスマッチから解放された話
tkawae
1
320
いまさら聞けない生成AI入門: 「生成AIを高速キャッチアップ」
soh9834
12
3.5k
Day0 初心者向けワークショップ実践!ソフトウェアテストの第一歩
satohiroyuki
0
350
PHPでお金を扱う時、終わりのない 謎の1円調査の旅にでなくて済む方法
nakka
3
980
Devin入門と最近のアップデートから見るDevinの進化 / Introduction to Devin and the Evolution of Devin as Seen in Recent Update
rkaga
7
3.5k
NestJSのコードからOpenAPIを自動生成する際の最適解を探す
astatsuya
0
180
Featured
See All Featured
A designer walks into a library…
pauljervisheath
205
24k
Making the Leap to Tech Lead
cromwellryan
133
9.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
We Have a Design System, Now What?
morganepeng
51
7.5k
Documentation Writing (for coders)
carmenintech
69
4.7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.4k
Making Projects Easy
brettharned
116
6.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
7
610
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
Bash Introduction
62gerente
611
210k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
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!