Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Navigationを使った業務プロセスのモジュール化

 Navigationを使った業務プロセスのモジュール化

https://fablic.connpass.com/event/239265/
ラクマ × Voicy × ANDPAD ~ Android開発の裏側 ~

の資料

53b0cf6dfd1077b8159c9f34607938e1?s=128

くどう

March 18, 2022
Tweet

More Decks by くどう

Other Decks in Programming

Transcript

  1. 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を使った業務プロセスのモジュール化
  2. 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とか使ってます
  3. 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コンポーネントを既存アプリへ導入した話 表っぽいキラキラした話ではなく裏っぽい地味な内容です
  4. 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. 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は現場の効率化から経営改善まで一元管理できる クラウド型建設プロジェクト管理サービスです
  6. 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の浸透率
  7. 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 短工事 検査 図面
  8. 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
  9. 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 無断転載・無断複製の禁止 アプリが増えると・・・?
  10. 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 無断転載・無断複製の禁止 同じ(ように見える)機能はどうする? わかりやすい機能はライブラリ化済み - カメラ - 写真ピッカー 建築ドメイン色が強かったりプロダクト固有の事情があると独自に実装さ れがち
  11. 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 ・・・
  12. 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)
  13. 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 無断転載・無断複製の禁止 既存アプリの課題
  14. 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を作った判断を批判する意図はありません
  15. 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や共通エラー監視・特定の種類の画面でしか使わない処理などが大事に保管 されています。本当は今すぐ消したい。
  16. 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や共通エラー監視・特定の種類の画面でしか使わない処理などが大事に保管 されています。本当は今すぐ消したい。
  17. 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
  18. 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で参照先見ればなんとかなる 大規模アプリ →もっと重要な課題がある
  19. 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とか
  20. 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 無断転載・無断複製の禁止 使い方
  21. 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 無断転載・無断複製の禁止 ナビゲーショングラフを作る
  22. 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 無断転載・無断複製の禁止 ナビゲーショングラフを作る <?xml version="1.0" encoding="utf-8"?> <navigation xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" app:startDestination="@id/blankFragment"> <fragment android:id="@+id/blankFragment" android:name="com.example.cashdog.cashdog.BlankFragment" android:label="@string/label_blank" tools:layout="@layout/fragment_blank" > <action android:id="@+id/action_blankFragment_to_blankFragment2" app:destination="@id/blankFragment2" /> </fragment> <fragment android:id="@+id/blankFragment2" android:name="com.example.cashdog.cashdog.BlankFragment2" android:label="@string/label_blank_2" tools:layout="@layout/fragment_blank_fragment2" /> </navigation>
  23. 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
  24. 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) }
  25. 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
  26. 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. 遷移処理を生成された関数に置き換え
  27. 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 無断転載・無断複製の禁止 使ってみてどうだったか
  28. 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 親子関係が変わらないので書いた処理と既存処理を比較しやすい リファクタリングの最初のステップとしては難易度が低い
  29. 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 無断転載・無断複製の禁止 作業コストが低め 構造を大きく変える必要がない →大掛かりなアーキテクチャ変更はリードタイムが長くなってしまう サービス的に意味のあるまとまった単位で改善できる →画面単位の改善だとミクロな視点になりがち
  30. 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の用途もわかりやすくなった
  31. 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 無断転載・無断複製の禁止 デメリット 普通にモジュール分割できているなら無理して使わなくても良いかも 画面遷移パターンを整理しないと着手しにくい(デメリット?)
  32. 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 無断転載・無断複製の禁止 まとめ
  33. 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脱却の糸口が見えた
  34. 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 無断転載・無断複製の禁止 ご清聴ありがとうございました
  35. 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 無断転載・無断複製の禁止 テンプレート