Slide 1

Slide 1 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ラクマ × Voicy × ANDPAD ~ Android開発の裏側 ~ 株式会社アンドパッド 工藤厚太郎 Navigationを使った業務プロセスのモジュール化

Slide 2

Slide 2 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 自己紹介 工藤厚太郎 開発本部 SWE モバイルアプリエンジニア 2020年1月入社 Twitter: derakudo 金融系SIer→toC向け事業会社→アンドパッド KotlinとかFlutterとか使ってます

Slide 3

Slide 3 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 今日話すこと Navigationコンポーネントを既存アプリへ導入した話 表っぽいキラキラした話ではなく裏っぽい地味な内容です

Slide 4

Slide 4 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 宣伝

Slide 5

Slide 5 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ANDPADとは ANDPADは現場の効率化から経営改善まで一元管理できる クラウド型建設プロジェクト管理サービスです

Slide 6

Slide 6 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 建築業界の課題 ペインポイント 市場規模 社会課題 ・人材不足 ・低生産性 現場課題 ・長時間残業 ・低粗利率 ●建設産業 50兆円市場 ●業者数 約50万社 特定建設業許可:45,742件 一般建設業許可:445,304件 ●従業者 約500万人 ●ANDPADの浸透率

Slide 7

Slide 7 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 モバイルアプリは5種類 施工管理のお悩みをすべて解決。豊富なアプリケーション群 ANDPAD CHAT 短工事 検査 図面

Slide 8

Slide 8 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 マルチアプリの詳しい話はこちら https://speakerdeck.com/andpad/fu-shu-falseapuriwotong-shi-niririsusinagarasabisug urosusaserufang-fa

Slide 9

Slide 9 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 アプリが増えると・・・?

Slide 10

Slide 10 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 同じ(ように見える)機能はどうする? わかりやすい機能はライブラリ化済み - カメラ - 写真ピッカー 建築ドメイン色が強かったりプロダクト固有の事情があると独自に実装さ れがち

Slide 11

Slide 11 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ログイン画面 APIエンドポイントが違っていたので別で実装していた セキュリティ改善でアプデが多め - SSO - クライアント証明書 - etc ・・・

Slide 12

Slide 12 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ライブラリ化した ANDPAD CHAT 短工事 検査 図面 アプリリポジトリからログイン処理を分離 AndpadAuth().startLoginProcess(context)

Slide 13

Slide 13 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 既存アプリの課題

Slide 14

Slide 14 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 BaseActivityがある ※補足 一番重要なのはアプリが価値を生み出すかなので、 BaseActivityを作った判断を批判する意図はありません

Slide 15

Slide 15 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 BaseActivityとは 画面の基本コンポーネントであるActivityを継承した神クラス。複数の画面で利用 する処理やボイラープレートを実装して各画面のActivityで継承して利用する古の デザインパターンです。神クラスなのでそれぞれ関係が無いけど重要な機能が集 まって可読性が落ちるといった問題が起こりがち。昔はライフサイクルメソッドに 連動した処理を切り出すのが難しかったので止む終えない感じもしましたが LifeCycleObserver等の登場によって過去の遺産となりました(多分)。 アンドパッドのBaseActivityも神として崇められた結果†Dagger†Componentの injectや共通エラー監視・特定の種類の画面でしか使わない処理などが大事に保管 されています。本当は今すぐ消したい。

Slide 16

Slide 16 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 BaseActivityとは 画面の基本コンポーネントであるActivityを継承した神クラス。複数の画面で利用 する処理やボイラープレートを実装して各画面のActivityで継承して利用する古の デザインパターンです。神クラスなのでそれぞれ関係が無いけど重要な機能が集 まって可読性が落ちるといった問題が起こりがち。昔はライフサイクルメソッドに 連動した処理を切り出すのが難しかったので止む終えない感じもしましたが LifeCycleObserver等の登場によって過去の遺産となりました(多分)。 アンドパッドのBaseActivityも神として崇められた結果†Dagger†Componentの injectや共通エラー監視・特定の種類の画面でしか使わない処理などが大事に保管 されています。本当は今すぐ消したい。

Slide 17

Slide 17 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 Navigationコンポーネントとは Google製の画面遷移を抽象化するライブラリ https://developer.android.com/guide/navigation?hl=ja

Slide 18

Slide 18 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 今までの印象 使うモチベーションがわからなかった 小規模アプリ →AndroidStudioで参照先見ればなんとかなる 大規模アプリ →もっと重要な課題がある

Slide 19

Slide 19 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 他にも - 部分導入できるのを知らなかった - 他のライブラリの方が興味ある。Hiltとか

Slide 20

Slide 20 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 使い方

Slide 21

Slide 21 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ナビゲーショングラフを作る

Slide 22

Slide 22 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ナビゲーショングラフを作る

Slide 23

Slide 23 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 Activityを作る val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment val navController = navHostFragment.navController

Slide 24

Slide 24 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 遷移方法を変える override fun onClick(view: View) { val action = SpecifyAmountFragmentDirections .actionSpecifyAmountFragmentToConfirmationFragment() view.findNavController().navigate(action) }

Slide 25

Slide 25 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 移行ステップ Developerサイトを参考にしました https://developer.android.com/guide/navigation/navigation-migrat e?hl=ja

Slide 26

Slide 26 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 1. BaseActivityをSingleActivityにする 2. 画面ActivityをFragmentに変換 3. ナビゲーショングラフを作る 4. 遷移処理を生成された関数に置き換え

Slide 27

Slide 27 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 使ってみてどうだったか

Slide 28

Slide 28 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 BaseActivity問題と相性が良かった BaseActivity Activity1 Activity2 Fragment1 Fragment2 ViewModel2 HostActivity Fragment1 Fragment2 ViewModel2 親子関係が変わらないので書いた処理と既存処理を比較しやすい リファクタリングの最初のステップとしては難易度が低い

Slide 29

Slide 29 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 作業コストが低め 構造を大きく変える必要がない →大掛かりなアーキテクチャ変更はリードタイムが長くなってしまう サービス的に意味のあるまとまった単位で改善できる →画面単位の改善だとミクロな視点になりがち

Slide 30

Slide 30 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 責務の分離 ヘッダーがある画面は Activityで実装? メインセクションはFragment にする? UIはFragment! Before After Activityの役割が明確になった = Fragmentの用途もわかりやすくなった

Slide 31

Slide 31 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 デメリット 普通にモジュール分割できているなら無理して使わなくても良いかも 画面遷移パターンを整理しないと着手しにくい(デメリット?)

Slide 32

Slide 32 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 まとめ

Slide 33

Slide 33 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 1. Navigationでライブラリを作った 2. BaseActivityとSingleActivityは相性 が良かった 3. BaseActivity脱却の糸口が見えた

Slide 34

Slide 34 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ご清聴ありがとうございました

Slide 35

Slide 35 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 テンプレート