Successfully reported this slideshow.
Your SlideShare is downloading. ×

DevFest 2022 - 為你的專案加點模組化.pdf

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 55 Ad

More Related Content

Recently uploaded (20)

Advertisement

DevFest 2022 - 為你的專案加點模組化.pdf

  1. 1. 為你的專案加點模組化 Kaohsiung YungHan Chang ( Kenny Chang ) Freelancer Android & Backend
  2. 2. 86% work on multi-module 90% would recommend considering.
  3. 3. Modularity of code is critical to managing complexity, stability, readability, and testability in an ever-growing codebase.
  4. 4. 54% dif fi cult to fi nd learning materials 95% of fi cial materials are insuf fi cient!
  5. 5. 綱要 ● 特點 ● Strategy ● Data domain presenter ● Feature ● Hybrid ● Dependency ● Gradle ● Library version control ● Now in android project
  6. 6. 不包含 ● Dynamic module ● Gradle syntax ● Benchmark ● Lint
  7. 7. 模組化 What and why
  8. 8. 顆粒度 Component Class function Gradle project
  9. 9. 顆粒度 Component Class function Gradle project
  10. 10. 顆粒度 ● 過於精細 ● 成本 ● 建構複雜度 ● 專案複雜度 ● 過於粗略 ● 變成另⼀個⼤模組,失去模組化優勢
  11. 11. Pros ● 只有模組化可以 ● 模組可重⽤性 ● 嚴格控制可⾒性 ● 動態發布 ● 模組化幫你增強 ● 關注點分離 ● 問責和單⼀權責 ● 封裝 ● 測試 ● 建構時間 ● 平⾏開發
  12. 12. “Nothing wrong with single module.”
  13. 13. App architecture
  14. 14. Layer seperation
  15. 15. Layer seperation
  16. 16. Layer seperation
  17. 17. Layer seperation
  18. 18. Benefit of layering ● Reducing scope of attention ● Increase testability ● Clearer responsibility ● One way direction dependency
  19. 19. But not good enough for modularization, because… :UI :Domain :Data
  20. 20. What if by features? :Store :Product :FeatureC Store ui Store view Model Store repository Store remote source Store local source
  21. 21. What if by features? :Store 20s :Product. 13s :FeatureC. 17s :app. 5s :Core. 4s
  22. 22. What if by features? :Store :Product :FeatureC Store ui Store view Model Store repository Store remote source Store local source Product ui Product view Model Product repository Product remote source Product ui Product remote source Product local source . . .
  23. 23. Why not depends on other feature? :Store 20s :Product. 13s :FeatureC. 17s :app. 5s :Core. 4s 59S
  24. 24. Combining two strategy :ui:Store :domain:Store :data:Store :ui:Product :domain:Product :data:Product :ui:C :domain:C :data:C
  25. 25. Challenge ● Gradle ● Circular Dependency ● Style ● Navigation ● DI ● Library version
  26. 26. Gradle incremental Build
  27. 27. Using api v.s. implementation ● api configuration will be transitively exposed to consumers of the library. ● implementation will not be exposed to consumer, and not leak into the consumer’s compile classpath.
  28. 28. Using api v.s. implementation Source : Android modularization preps things to know before modularizing
  29. 29. Circular dependencies Source : Android modularization preps things to know before modularizing
  30. 30. Library version ● BuildSrc module ● Version catalog :app
  31. 31. Using gradle control library version ● BuildSrc module ● Version catalog :app
  32. 32. Now in Android App Architecture
  33. 33. Now in Android modularization
  34. 34. Feature module
  35. 35. Core module
  36. 36. Data module NowInAndroid Single feature
  37. 37. :feature:author ● Grade
  38. 38. :build-logic ● Grade
  39. 39. :build-logic gradle
  40. 40. :core:data
  41. 41. Using different module in app module
  42. 42. Kotlin project
  43. 43. KMM
  44. 44. KMM
  45. 45. 模組化和抽象⼀樣,適度就好
  46. 46. 沒有最好的架構,只有最適合的
  47. 47. It depends…
  48. 48. Resource ● Android ● https://android-developers.googleblog.com/2022/09/announcing-new-guide-to- android-app-modularization.html ● https://developer.android.com/topic/modularization ● https://developer.android.com/topic/architecture ● https://developer.android.com/topic/modularization/patterns#types-of-modules ● https://www.droidcon.com/2022/02/15/android-modularization-preps-things-to-know- before-modularizing-your-app/ ● https://github.com/android/nowinandroid/blob/main/docs/ ModularizationLearningJourney.md ● https://www.youtube.com/watch?v=16SwTvzDO0A
  49. 49. Resource ● Modularization ● https://proandroiddev.com/the-abc-of-modularization-for-android-in-2021- e7b3fbe29fca ● https://www.droidcon.com/2022/11/15/modularization-flatten-your-graph-and-get-the- real-benefits/ ● https://www.jetbrains.com/help/idea/dependencies-analysis.html#validate- dependencies ● https://www.droidcon.com/2022/06/28/solid-modularization-untangling-the- dependency-graph/ ● https://markonovakovic.medium.com/clean-architecture-is-not-domain-data- presentation-e368d7ff8579 ● https://martinfowler.com/bliki/PresentationDomainDataLayering.html
  50. 50. Resource ● Library version ● https://proandroiddev.com/using-version-catalog-on-android-projects-82d88d2f79e5 ● https://proandroiddev.com/stop-using-gradle-buildsrc-use-composite-builds- instead-3c38ac7a2ab3 ● https://quickbirdstudios.com/blog/gradle-kotlin-buildsrc-plugin-android/ ● https://www.droidcon.com/2021/07/19/better-dependency-management-using- buildsrc-kotlin-dsl/ ● https://www.droidcon.com/2022/05/13/gradle-version-catalogs-for-an-awesome- dependency-management/ ● https://docs.gradle.org/current/userguide/platforms.html
  51. 51. Q&A

×