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

Best practices for a modularized app with dynam...

Best practices for a modularized app with dynamic features

LINE DevDay 2020

November 26, 2020
Tweet

More Decks by LINE DevDay 2020

Other Decks in Technology

Transcript

  1. LINE History & Features › 2011: Free text messaging, Free

    Calls, Stickers › 2012: Home, Timeline › 2013: Video calls › 2014: “LINE Premium Call” More Services & Features: LINE Out (LINE Premium Call), LINE Pay, LINE NEWS, LINE Shopping, LINE MUSIC, LINE Official Account, LINE Ads, LINE LIVE, LINE Coupon, LINE Kakeibo, LINE Meeting, LINE Square (Open Chat), LINE Sticker Premium, Timeline Stories, FacePlay, Icons Suggestion, Android wear support, Combined Search, Pop-up Stickers, In-App Browser, LIFF (LINE Front-end framework), BLE support, quick reply, Dark mode ...
  2. LINE Android Project Status in 2019 › 100+ contributors at

    the main repository › 33 modules › 1.4 million lines of source code
  3. Issues of App Module with 66% Code › Unreadable structure

    › Slow build time: ≈17mins (for the first build without remote cache) › Large app size: ≈248MB
  4. Current Modularization Project status › New 20 modules are created

    › New 0.27M lines of source code are created in separate modules (Still ongoing) › 10% of source code in app modules are moved to other modules
  5. Four types of modules in a multi-module android app ›

    Dynamic Feature Module › Android Library Module › Application Module › Pure Java/Kotlin Library Module
  6. Four types of modules in a multi-module android app ›

    Dynamic Feature Module › Android Library Module › Application Module › Pure Java/Kotlin Library Module
  7. › Is a standalone module › Can be reused by

    other apps › Is for library development › Improves build time Library Module › Depends on Application Module › Can delay the delivery (onDemand/ Instant) › Improves build time › Reduce app size Dynamic Feature Module Difference between Library and Feature module
  8. › Uses Library Module › Splits independent utility/library › May

    require large refactoring Top-down: › Uses Dynamic Feature Module › Splits features depending on app module › May minimize affected code Bottom-up: Two different approaches
  9. › Uses Library Module › Splits independent utility/library › May

    require large refactoring Top-down: › Uses Dynamic Feature Module › Splits features depending on app module › May minimize affected code Bottom-up: Two different approaches
  10. › Uses Library Module › Splits independent utility/library › May

    require large refactoring Top-down: › Uses Dynamic Feature Module › Splits features depending on app module › May minimize affected code Bottom-up: Two different approaches
  11. Top-down (Library module) Bottom-up (Feature module) Access App Module Can’t

    Can Refactoring cost High Small Side-effect Large Limited
  12. › Testability: › Performance: › Dependency Structure: Disadvantages of Dynamic

    Feature Module › 50+ installed features on single device lead to performance issue › 10+ removable install-time delivery modules increase the download and install time › Known Issues: › Uploaded bundle required › Data Binding issue and Unit Testing issue › Dynamic feature module depends on application module
  13. Best Practices › Set ProGuard rule for data binding ›

    Use Service Locator › Decide conventions of resources › Manage Library version at root directory For Dynamic Feature Modules › Separate interface and implementation at different modules
  14. Best Practice #1: Use Service Locator Lich Component Library (https://github.com/line/lich/tree/master/component)

    Related talk: Modernize the development of LINE Messenger for android - Masakuni Oishi (https://speakerdeck.com/line_devday2019/ modernize-the-development-of-line-messenger-for- android)
  15. Best Practices › Set ProGuard rule for data binding ›

    Use Service Locator › Decide conventions of resources › Manage Library version at root directory For Dynamic Feature Modules › Separate interface and implementation at different modules
  16. Data Binding with obfuscation: Solution › Best Practice #2: Set

    a ProGuard rule to keep `DataBinderMapper` classes name explicitly
  17. Best Practices › Set ProGuard rule for data binding ›

    Use Service Locator › Decide conventions of resources › Manage Library version at root directory For Dynamic Feature Modules › Separate interface and implementation at different modules
  18. Resources conflict: Solution › Add module name prefix › Create

    a common resources library › Best Practice #3: Decide conventions to avoid ID conflicts
  19. Best Practices › Set ProGuard rule for data binding ›

    Use Service Locator › Decide conventions of resources › Manage Library version at root directory For Dynamic Feature Modules › Separate interface and implementation at different modules
  20. Best Practices › Set ProGuard rule for data binding ›

    Use Service Locator › Decide conventions of resources › Manage Library version at root directory For Dynamic Feature Modules › Separate interface and implementation at different modules
  21. Best Practice #5: Separate interface and implementation at different modules

    › Can reuse the feature on the other apps › Restrict the unnecessary dependency › Can easily convert the dynamic feature module to android library module
  22. Dynamic Feature Module: Android Library Module: Best Practice #5: Separate

    interface and implementation at different modules
  23. Summary › Avoid using any classes or resources from the

    app module in feature modules › Modularize your app as soon as possible › Apply dynamic feature module ONLY when it is necessary
  24. More information Sharing experiences of adapting AppBundle on LINE Android

    CI (Young-Cha) › About how to adapt dynamic feature module on CI Enforcing code conventions with Lint (Daniel Vila) › Using lint to maintain the code health of your modular app project