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

How Modularization Speed Up Your Team

How Modularization Speed Up Your Team

For big projects with a large team or multiple teams working on a single big project. Developers will continue to add new features throughout an application's lifetime. More code means not only longer build times — it means longer incremental build time
Furthermore, the needed of separation/decoupling the code to avoid conflict between the team/feature become a must

Minh Nguyen

April 07, 2018
Tweet

Other Decks in Programming

Transcript

  1. Hello! Nguyen Van Minh Android Engineer at Grab Singapore You

    can find me at: https://twitter.com/MinhDev88 https://www.linkedin.com/in/minhnguyenvan
  2. Scenario Big projects with a large team or multiple teams

    working on a single big project ◦ Build time ◦ Separation & decoupling the code become necessary
  3. Contents 1. Monolith difficulties 2. How modularization improve your build

    time 3. Enforce separate/decouple the code 4. Experience sharing 5. Q&A
  4. APP FeatureA Package FeatureB Package PRESENTATION DOMAIN DATA RESOURCE PRESENTATION

    DOMAIN DATA RESOURCE Monolith Difficulties • Code coupling • Feature colliding • Conflicts • Instant app ?
  5. Build Process Phrases Dependencies Preparation Processing Resource & Manifest Compiling

    Postprocessing Packing&Publishing Tasks Run In ORDER Some parallelism within a task limited
  6. Module B (org.gradle.parallel = true) Dependencies Preparation Processing Resource &

    Manifest Compiling Postprocessing Packing&Publishing Tasks Run In Parallel Module A Dependencies Preparation Processing Resource & Manifest Compiling Postprocessing Packing&Publishing Build Process Phrases
  7. Android Plugin for Gradle from 3.0.0 Compile • Implementation •

    Api Pre - Android Plugin for Gradle 3.0.0 Gradle Configuration
  8. Api, compile Api vs implementation App ModuleA1 ModuleB1 ModuleA2 ModuleB2

    ModuleB3 Implementation App ModuleA1 ModuleB1 ModuleA2 ModuleB2 ModuleB3 Gradle Configuration
  9. Api, compile Api vs implementation App ModuleA1 ModuleB1 ModuleA2 ModuleB2

    ModuleB3(Code Update) Implementation App ModuleA1 ModuleB1 ModuleA2 ModuleB2 ModuleB3(Code Update) Gradle Configuration
  10. Api, compile Api vs implementation App ModuleA1 ModuleB1 ModuleA2 ModuleB2

    ModuleB3(Code Update) Implementation App ModuleA1 ModuleB1 ModuleA2 ModuleB2 ModuleB3(Code Update) Gradle Configuration
  11. App Module0 Module1 Module2 Module3 Module4 Module5 Module6 Module7 Module10

    Module9 Module8 Module13 Module12 Module11 Module14 Example Projects
  12. TABLES OF RESULT CLEAN BUILD Incremental (small change) 1 Module

    180s 19s 16 Modules 40s 7s 16 Modules (parallel) 29s 5s Run on Android Plugin 3.0.1 + Gradle 4.1
  13. “ How the dependencies tree is and the number of

    classes/methods in each module decide your build time.
  14. Break down the codebase to multiple modules along with the

    limitation of code accessing Modularization
  15. FeatureA module FeatureB Module PRESENTATION DOMAIN DATA RESOURCE PRESENTATION DOMAIN

    DATA RESOURCE • Real reason to create a dependence between two modules • Modules should be as independent as possible Modularization
  16. App ModuleA ModuleB ModuleC InterfaceModule InterfaceA & InterfaceB Implement InterfaceA

    Implement InterfaceB Use InterfaceA and InterfaceB Provide InterfaceA & InterfaceB Example
  17. Independent ◦ Force to decouple the code between modules ◦

    Rely on interfaces & abstraction ◦ Reduce code/features colliding ◦ Cleaner Codebase/Architecture ◦ Reuse the modules in other projects Multiple dev/team can work in parallel Modularization
  18. App Main FeatureB Main FeatureC Main FeatureD ... Main FeatureA

    Modularization Abstractions Module2 Common Module2 Lib-Module2 Abstractions Module1 Common Module1 Lib-Module1
  19. Dependencies Preparation Processing Resource & Manifest Compiling Postprocessing Packing&Publishing Create

    pure Java/Kotlin module Try to group class which use annotation processors in the same modules Building Process Phases
  20. App Module0 Module1 Module2 Module3 Module4 Module5 Module6 Module7 Module10

    Module9 Module8 Module13 Module12 Module11 Module14 The rest of the project have to wait Module14 to be build. And no parallel tasks is being executed Experience Sharing
  21. App Module0 Module1 Module2 Module3 Module4 Module5 Module6 Module7 Module10

    Module9 Module8 App module always be built Experience Sharing
  22. App Module0 Module1 Module6 Large-Module Module9 Module8 Consider to add

    Interfaces Module FrequentlyUpdateModule Experience Sharing
  23. Evaluate build time with the config (call it ‘T’) org.gradle.workers.max

    = 1 idealBuildTime ~ T / numberOfWorker Compare your build time with the idealBuildTime ◦ How to measure the dependencies work effectively Experience Sharing
  24. • Export to aar or jar files if the modules

    are stable Import directly to Project Binary Repository Manager Experience Sharing
  25. • Proguard consumerProguardFiles 'lib-proguard-rules.txt' • Build errors while adding/removing modules

    ./gradlew cleanBuildCache clean ./gradlew clean assembleDebug --no-build-cache • Dagger 2 Component.Builder Subcomponent.Builder Uses dagger.android package Use Dependency component Experience Sharing