App Modularization: From Zero to Hero

App Modularization: From Zero to Hero

As your app becomes more complex and build speeds begin to increase, app modularization starts to enter the conversation. Does the concept seem fuzzy to you? Or, do you know what it means in theory but have no clue where to start in your apps?

In this talk, you will get an answer to the Five Ws on app modularization - what, why, when, where and how. You'll learn:

What Dynamic Feature Modules are and how that relates to modularization
How to identify features to modularize and all the steps to take in the process
All the pain points to look out for based on our experience

You'll get all the information you need to modularize your apps and reap the benefits!

E803718649600ddffc1bc625d957e786?s=128

Moyinoluwa Adeyemi

August 09, 2019
Tweet

Transcript

  1. APP MODULARIzation: FROM ZERO TO HERO! Moyinoluwa Adeyemi @moyheen

  2. APP “Separating logical components of your app project into discrete

    modules” 2
  3. WHY? 3

  4. WHY? × Cleaner codebase 4

  5. WHY? × Cleaner codebase × Separation of concerns 5

  6. WHY? × Cleaner codebase × Separation of concerns × Faster

    build times 6
  7. WHY? × Cleaner codebase × Separation of concerns × Faster

    build times × Dynamic delivery 7
  8. WHY? × Cleaner codebase × Separation of concerns × Faster

    build times × Dynamic delivery × App Bundles 8
  9. When? 9

  10. WHEN? start? 10

  11. WHEN? start? middle? 11

  12. WHEN? start? middle? middle? 12

  13. WhO? 13

  14. YOU, SITTING IN THIS TALK? 14

  15. WHERE? 15

  16. IT DEPENDS! 16

  17. ZOLA APP 17

  18. ZOLA APP 18

  19. HOW? 19

  20. dYNAMIC FEATURE MODULES 20

  21. dYNAMIC FEATURE MODULES 21

  22. dYNAMIC FEATURE MODULES 22

  23. ARCHITECTURE - IN THE BEGINNING 23 :app

  24. ARCHITECTURE - MULTIPLE MODULES (FIRST PASS) 24 :database :app

  25. ARCHITECTURE - MULTIPLE MODULES (FIRST PASS) 25 :database :order :lead

    :service :installation :app :inventory
  26. ARCHITECTURE - MULTIPLE MODULES (SECOND PASS) 26 :database

  27. ARCHITECTURE - MULTIPLE MODULES (SECOND PASS) 27 :database :core

  28. ARCHITECTURE - MULTIPLE MODULES (SECOND PASS) 28 :database :test_shared :core

  29. ARCHITECTURE - MULTIPLE MODULES (SECOND PASS) 29 :database :core :app

    :test_shared
  30. ARCHITECTURE - MULTIPLE MODULES (SECOND PASS) 30 :database :order :lead

    :service :installation :core :inventory :app :test_shared
  31. MANIFEST.XML FILE <dist:module dist:instant="false" dist:onDemand="false" dist:title="@string/title_dynamic_feature"> <dist:fusing dist:include="true" /> </dist:module>

    31
  32. MANIFEST.XML FILE - INTENT FILTER <activity android:name=".DynamicFeatureActivity"> <intent-filter> <action android:name="android.intent.action.VIEW"

    /> </intent-filter> </activity> 32
  33. START ACTIVITY FROM A DIFFERENT MODULE fun goToTasks(context: Context) =

    Intent(Intent.ACTION_VIEW).apply { setClassName(context.packageName, "$BASE_PACKAGE.features.service.TasksActivity") } 33
  34. 34 SETTINGS.GRADLE FILE (ROOT) include ':app', ':dynamic_feature'

  35. 35 BUILD.GRADLE FILE (APP) dynamicFeatures = [":dynamic_feature"]

  36. 36 CORE_TEST_DEPEndencies.GRADLE FILE (ROOT) apply from: '../core_test_dependencies.gradle'

  37. R class import com.offgrid.electric.confetti.R import com.offgrid.electric.confetti.features.order.R as orderR 37

  38. R class override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(orderR.layout.activity_customer_edit) 38

  39. CONTINUOUS INTEGRATION 39

  40. ANY GOTCHAS? 40

  41. APOLLO GRAPHQL ‍♀ 41 “Couldn’t find some schema files for

    the variant stagingDebug. Please ensure a valid schema.json file exists under the variant source sets”
  42. APOLLO GRAPHQL 42 sourceSets { main { java.srcDirs += ['src/main/graphql']

    } }
  43. APOLLO GRAPHQL 43 apollo { customTypeMapping = ["DateTime": "java.util.Date"] schemaFilePath

    = "../../com/my/example/schema.json" outputPackageName = "com.my.example.features.feature" }
  44. DEPENDENCY INJECTION with dagger - thE problem 44 http://adavis.info/2019/06/dagger-multibinding-in-dynamic-feature-modules.html

  45. DEPENDENCY INJECTION with dagger - thE problem 45 http://adavis.info/2019/06/dagger-multibinding-in-dynamic-feature-modules.html class

    ConfettiJobCreator @Inject constructor( private val jobs: @JvmSuppressWildcards Map<String, Provider<Job>> ) : JobCreator { override fun create(tag: String): Job? = jobs[tag]?.get() }
  46. DEPENDENCY INJECTION with dagger - thE problem 46 http://adavis.info/2019/06/dagger-multibinding-in-dynamic-feature-modules.html ...

    @Binds @IntoMap @StringKey(SomeJob.JOB_TAG) internal abstract fun bindSomeJob(job: SomeJob): Job ...
  47. DEPENDENCY INJECTION with dagger - thE problem 47 http://adavis.info/2019/06/dagger-multibinding-in-dynamic-feature-modules.html

  48. DEPENDENCY INJECTION with dagger - the solution 48 http://adavis.info/2019/06/dagger-multibinding-in-dynamic-feature-modules.html

  49. 49 Localization - l10n Handling multiple string.xml files while using

    a translation tool?
  50. Unit tests 50

  51. Unit tests 51

  52. DISTRIBUTION 52

  53. Credits × Presentation template by SlidesCarnival × http://adavis.info/2019/06/dagger-multibinding-in-dynamic-feature-modul es.html ×

    https://github.com/android/plaid × https://codelabs.developers.google.com/codelabs/your-first-dynamic-app × https://medium.com/androiddevelopers/a-patchwork-plaid-monolith-to- modularized-app-60235d9f212e 53
  54. THANKS! Moyinoluwa Adeyemi @moyheen 54