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

Feature Flag Best Practices - A case study of LINE Android

Feature Flag Best Practices - A case study of LINE Android

Eebedc2ee7ff95ffb9d9102c6d4a065c?s=128

LINE DevDay 2020

November 26, 2020
Tweet

Transcript

  1. None
  2. Introduction > LINE Android development Hidetsugu Tamaki > Apr. 2018

    ~ > Software Engineer
  3. Agenda › What is Feature Flag-based development? › Best Practice

    1: Change logic with Feature Flag › Best Practice 2: Guard the only entry point
  4. Agenda › What is Feature Flag-based development? › Best Practice

    1: Change logic with Feature Flag › Best Practice 2: Guard the only entry point
  5. Feature Branch Strategy Main branch Sticker feature branch Pull requests

  6. Feature Flag Strategy Main branch Sticker feature PRs

  7. Feature Flag Strategy Main branch Sticker feature PRs val FEATURE_STICKER

    = false
  8. Feature Flag Strategy Main branch Sticker feature PRs val FEATURE_STICKER

    = false true
  9. Feature Flag Achieves > Instant toggling > Smoother release schedule

    management > Conflict minimization > Better collaboration with stakeholders
  10. Feature Flag Achieves > Instant toggling > Smoother release schedule

    management > Conflict minimization > Better collaboration with stakeholders
  11. References https://youtu.be/tQ56xi-j88s Presented at LINE DEV DAY 2019 https://speakerdeck.com/line_devday2019/journey-of-feature-flag-development-in-line-android https://youtu.be/H81EEAZ4XAI

    Presented at DroidKaigi 2019 https://speakerdeck.com/line_developers/flag-based-feature-management
  12. Agenda › What is Feature Flag-based development? › Best Practice

    1: Change logic with Feature Flag › Best Practice 2: Guard the only entry point
  13. Case Study: Refactoring Complex Logic Local Storage

  14. Case Study: Refactoring Complex Logic Logics Local Storage

  15. Structure of Image File Managers > Scattered logics UseCase ImageFilePathUtil

    StorageUtil ImageUtil Depends on ImageFileManager BaseFileManager
  16. BaseFileManager Structure of Image File Managers > Scattered logics UseCase

    ImageFilePathUtil StorageUtil ImageUtil ImageFileManager Depends on OldFileManager
  17. Structure of Image File Managers > New logics applied one

    by one UseCase NewFileManager ✗ ✗ ✗ OldFileManager
  18. ✗ ✗ ✗ NewFileManager OldFileManager Structure of Image File Managers

    > New logics applied one by one UseCase No Feature Flag to toggle
  19. Problem: Hard to Revert > Critical if many bugs reported

    Main branch Problematic PR Dependency Revert Conflict ! Another PR
  20. Best Practice: Change Logic with Feature Flag UseCase OldFileManager NewFileManager

    val FEATURE_REFACTORING = true Change Reference val FEATURE_REFACTORING = false
  21. Agenda › What is Feature Flag-based development? › Best Practice

    1: Change Logic with Feature Flag › Best Practice 2: Guard the only entry point
  22. Case Study: New Recommendation Feature

  23. Case Study: New Recommendation Feature WorkManager Enqueue Query Server

  24. Case Study: New Recommendation Feature Local Storage WorkManager Cache Enqueue

    Query Server
  25. Case Study: New Recommendation Feature Local Storage WorkManager Cache Display

    Enqueue Query Server
  26. Case Study: New Recommendation Feature Local Storage WorkManager Cache Display

    Enqueue Query Server
  27. Best Practice: Guard the Only Entry Point Enqueue ✗ val

    FEATURE_RECOMMENDATION = false
  28. Code Using Feature Flag // Application initialization function fun onCreate()

    { // The other initialization codes if (FeatureFlag.HOME_TAB_RECOMMENDATION) { val periodicSyncRequest: WorkRequest = … WorkManager.getInstance(…).enqueue(periodicSyncRequest) } }
  29. Case Study: Replace Message ListView MessageListActivity MessageListViewAdapter ListView API

  30. Case Study: Replace Message ListView MessageListActivity MessageListViewAdapter ListView API

  31. MessageListViewAdapter Case Study: Replace Message ListView MessageListActivity ListView API ListView

    API
  32. MessageListViewAdapter Case Study: Replace Message ListView MessageListActivity ListView API MessageListAdapterInterface

  33. MessageListViewAdapter Case Study: Replace Message ListView MessageListActivity MessageListAdapterInterface

  34. MessageListViewAdapter Case Study: Replace Message ListView MessageListActivity MessageListAdapterInterface MessageRecyclerViewAdapter

  35. MessageListViewAdapter Best Practice: Guard the Only Entry Point MessageListActivity MessageListAdapterInterface

    MessageRecyclerViewAdapter val RECYCLER_VIEW_REPLACEMENT = false val RECYCLER_VIEW_REPLACEMENT = true Change Implementation
  36. Code Using Feature Flag val adapter = if (FeatureFlag.RECYCLER_VIEW_REPLACEMENT) {

    MessageRecyclerViewAdapter(…) } else { MessageListViewAdapter(…) } setAdapter(adapter)
  37. > Minimize reverting cost with instant toggling Summary > Find

    a single entry point for easiest application
  38. Thank you