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

Journey of Feature Flag development in LINE Android

Journey of Feature Flag development in LINE Android

GDG DevFest Tokyo 2019 での講演資料です
https://tokyo.gdgjapan.org/devfest2019

LINE Developers
PRO

December 14, 2019
Tweet

More Decks by LINE Developers

Other Decks in Technology

Transcript

  1. Journey of Feature Flag
    development in LINE Android
    > Hidetsugu Tamaki / LINE Corporation

    View Slide

  2. > LINE Android Development
    Hidetsugu Tamaki (@r_ralph_h)
    Introduction
    > Apr. 2018 ~
    > LINE Corporation / Software Engineer

    View Slide

  3. Agenda > Pain Points of Feature Branches
    > Benefits of Feature Flags
    > History of Feature Flags in LINE Android

    View Slide

  4. Agenda > Pain Points of Feature Branches
    > Benefits of Feature Flags
    > History of Feature Flags in LINE Android

    View Slide

  5. Feature Branch
    Main branch

    View Slide

  6. Feature Branch
    Main branch
    Feature branch

    View Slide

  7. Feature Branch
    Main branch
    Feature branch
    Pull requests

    View Slide

  8. Feature Branch
    Main branch
    Feature branch
    Pull requests

    View Slide

  9. LINE Android Project
    Developers
    100
    Changes per week in LoC
    20,000

    View Slide

  10. Feature Branches in Large Applications
    Main branch
    Feature branches

    View Slide

  11. Agenda > Pain Points of Feature Branches
    > Benefits of Feature Flags
    > History of Feature Flag in LINE Android

    View Slide

  12. Feature Flag Strategy
    Main branch
    Sticker feature PRs

    View Slide

  13. Feature Flag Strategy
    Main branch

    Sticker feature PRs

    View Slide

  14. Feature Flag Strategy
    Main branch

    Sticker feature PRs

    View Slide

  15. Feature Flag Usage
    > View visibility
    . .. .

    View Slide

  16. Feature Flag Usage
    > Activity
    , ,
    =
    ( ) :
    =
    ( .) :
    > View visibility
    , ,

    View Slide

  17. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  18. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  19. Conflict Minimization
    Main branch
    Sticker feature PRs

    View Slide

  20. Conflict Minimization
    Main branch
    Sticker feature PRs
    Theme feature PRs

    View Slide

  21. Conflict Minimization
    Main branch
    Sticker feature PRs
    Theme feature PRs
    Saved PRs Saved PRs

    View Slide

  22. Conflict Minimization
    Main branch
    Sticker feature PRs
    Theme feature PRs
    Conflict
    Saved PRs Saved PRs

    View Slide

  23. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  24. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  25. Smoother Release Schedule Management
    Main branch
    Sticker feature PRs

    View Slide

  26. Smoother Release Schedule Management
    Main branch
    Release branches 1.0
    Sticker feature PRs

    View Slide

  27. Smoother Release Schedule Management
    Main branch
    Release branches 1.0


    Sticker feature PRs

    View Slide

  28. Smoother Release Schedule Management
    Main branch
    Release branches 1.0 2.0
    Sticker feature PRs




    View Slide

  29. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  30. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  31. Instant Toggling
    Main branch
    Release branch 1.0

    Sticker feature PR

    View Slide

  32. Sticker feature PR

    Instant Toggling
    Main branch
    Release branch 1.0
    Critical issue

    View Slide

  33. Instant Toggling
    Main branch
    Release branch 1.0
    Critical issue
    Sticker feature PR Conflicting PR


    View Slide


  34. Instant Toggling
    Main branch
    Release branch 1.0
    Critical issue
    Conflicting PR
    Sticker feature PR

    View Slide

  35. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  36. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  37. Better Collaboration with Stakeholders
    Developer Planner
    Tester
    Designer


    Organization

    View Slide

  38. Better Collaboration with Stakeholders
    Developer Planner
    Tester
    Designer
    Users
    Partners


    Organization


    View Slide

  39. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  40. Feature Flags Achieve
    > Conflict minimization
    > Smoother release schedule management
    > Instant toggling
    > Better collaboration with stakeholders

    View Slide

  41. Limitation of Feature Flags
    Not a “silver bullet”
    > Difficult to apply
    > Updating libraries
    > Overkill
    > Prototyping

    View Slide

  42. Reference
    ./ 1 1
    Presented at DroidKaigi 2019
    https://speakerdeck.com/line_developers/flag-based-feature-management

    View Slide

  43. Agenda > Pain Points of Feature Branches
    > Benefits of Feature Flags
    > History of Feature Flags in LINE Android

    View Slide

  44. Feature Flags in LINE Android
    > Started with a simple Gradle script (Dec. 2015)
    > Injects values into BuildConfig file
    > Loads values from a property file

    View Slide

  45. Feature Flags in LINE Android
    > Started with a simple Gradle script (Dec. 2015)
    > Injects values into BuildConfig file
    = = =
    # . "
    = = =
    # . "
    > Loads values from a property file

    View Slide

  46. Feature Flags in LINE Android
    > Started with a simple Gradle script (Dec. 2015)
    > Injects values into BuildConfig file


    > Loads values from a property file

    View Slide

  47. > Toggle flag by user name or app version
    > Toggle flag at runtime
    > Support Gradle submodule
    Growth of Feature Flags

    View Slide

  48. > Toggle flag by user name or app version
    > Toggle flag at runtime
    > Support Gradle submodule
    Growth of Feature Flags

    View Slide

  49. Module Structure of LINE Android
    line-android-app submodule-sticker
    Product Flavor Product Flavor

    View Slide

  50. Module Structure of LINE Android
    line-android-app submodule-sticker
    Product Flavor Product Flavor

    dev, beta, rc, release debug, release

    View Slide

  51. Initial Feature Flags Implementation
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    Refers to
    Product Flavor
    submodule-sticker

    View Slide

  52. Initial Feature Flags Implementation
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    BuildConfig.java
    Injects values into
    Product Flavor
    submodule-sticker
    Refers to

    View Slide

  53. Misused Feature Flags in Submodules
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    BuildConfig.java
    FeatureFlag script
    Product Flavor
    BuildConfig.java
    submodule-sticker
    Refers to
    Injects values into
    Refers to
    Injects values into

    View Slide

  54. Misused Feature Flags in Submodules
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    BuildConfig.java
    FeatureFlag script
    Product Flavor
    BuildConfig.java
    submodule-sticker
    Back reference

    Refers to
    Injects values into
    Refers to
    Injects values into

    View Slide

  55. Misused Feature Flags in Submodules
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    BuildConfig.java
    FeatureFlag script
    Product Flavor
    BuildConfig.java
    dev, beta, rc, release debug, release
    submodule-sticker
    Back reference

    Refers to
    Injects values into
    Refers to
    Injects values into

    View Slide

  56. Misused Feature Flags in Submodules
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    BuildConfig.java
    FeatureFlag script
    Product Flavor
    BuildConfig.java
    package com.linecorp.line package com.linecorp.sticker
    dev, beta, rc, release debug, release
    submodule-sticker
    Back reference

    Refers to
    Injects values into
    Refers to
    Injects values into

    View Slide

  57. Problems of Misuse
    > Caused by BuildConfig.java and product flavors
    > Generated wrong values
    > Caused by back reference
    > Submodules were no longer standalone

    View Slide

  58. Problems of Misuse
    > Caused by BuildConfig.java and product flavors
    > Generated wrong values
    > Caused by back reference
    > Submodules were no longer standalone

    View Slide

  59. Workaround for Wrong Flag Values
    Simplified references by extracting Feature Flags into a module

    View Slide

  60. Workaround for Wrong Flag Values
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    BuildConfig.java
    FeatureFlag script
    Product Flavor
    BuildConfig.java
    submodule-sticker
    Back reference

    Refers to
    Injects values into
    Refers to
    Injects values into

    View Slide

  61. Workaround for Wrong Flag Values
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    BuildConfig.java
    FeatureFlag script
    feature-flag
    BuildConfig.java
    Refers to
    submodule-sticker

    Refers to
    Injects values into
    Injects values into

    View Slide

  62. Workaround for Wrong Flag Values
    BuildConfig.java
    BuildConfig.java
    Injects values into
    Injects values into
    package com.linecorp.line
    package com.linecorp.sticker

    View Slide

  63. Workaround for Wrong Flag Values
    FeatureFlag.java
    FeatureFlag.java
    Creates
    Creates
    package com.linecorp.line
    package com.linecorp.line

    View Slide

  64. Workaround for Wrong Flag Values
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    FeatureFlag script
    feature-flag
    FeatureFlag.java
    Refers to
    submodule-sticker

    Refers to
    Creates
    Creates

    View Slide



  65. Workaround for Wrong Flag Values
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    FeatureFlag script
    feature-flag
    FeatureFlag.java
    Refers to
    submodule-sticker


    Refers to
    Creates
    Creates

    View Slide

  66. Workaround for Wrong Flag Values
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    submodule-sticker

    Refers to
    Creates

    View Slide

  67. Things Got Worse
    > Tricky usage of `

    > Wrong dependencies still remain
    > Poor compatibility with automated testing

    View Slide

  68. Things Got Worse
    > Tricky usage of `

    > Wrong dependencies still remain
    > Poor compatibility with automated testing

    View Slide

  69. Things Got Worse
    > Tricky usage of `

    > Wrong dependencies still remain
    > Poor compatibility with automated testing

    View Slide

  70. Things Got Worse
    > Tricky usage of `

    > Wrong dependencies still remain
    > Poor compatibility with automated testing

    View Slide

  71. Things Got Worse
    > Tricky usage of `

    > Wrong dependencies still remain
    > Poor compatibility with automated testing

    View Slide

  72. Proper Solution
    Isolated dependencies by processing flags within modules

    View Slide

  73. Proper Solution
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    submodule-sticker

    Refers to
    Creates

    View Slide

  74. Proper Solution
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    submodule-sticker

    Refers to
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    Refers to
    Creates Creates

    View Slide

  75. Flag Property File
    Product Flavor
    Proper Solution
    debug, release

    View Slide

  76. FeatureFlag.java FeatureFlag.java
    Proper Solution
    package com.linecorp.line package com.linecorp.sticker

    View Slide

  77. Proper Solution
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    submodule-sticker

    Refers to
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    Refers to
    Links to
    Creates Creates

    View Slide

  78. Proper Solution
    line-android-app
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    submodule-sticker

    Refers to
    FeatureFlag script
    Flag Property File
    Product Flavor
    FeatureFlag.java
    Refers to
    Links to
    Refers to
    Creates Creates

    View Slide

  79. Link to Submodule Flag Values
    &,
    A = A
    :



    &, -
    line-android-app
    submodule-sticker

    View Slide

  80. )(& ,( - (,
    = =
    :



    )(& ,( - (,
    = =
    :



    Property Parsing: Format
    > Written with “disjunctive normal form” style property

    View Slide

  81. Property Parsing: Phase
    > Enabled if build variant is
    Phase
    Phase
    > Enabled if build variant is

    View Slide

  82. Property Parsing: Value Calculation
    variant
    ( - -)&
    :
    =



    ( - -)& :
    =



    ( - -)&
    Optimization
    Phase resolution

    View Slide

  83. ( - -)&
    :
    =



    Property Parsing: Value Calculation
    variant
    Optimization
    Phase resolution
    ( - -)& :
    =



    ( - -)&

    View Slide

  84. Property Parsing: Value Calculation
    ( - -)&
    :
    =



    variant
    Optimization
    Phase resolution
    ( - -)& :
    =



    ( - -)&

    View Slide

  85. Property Parsing: Value Calculation
    variant
    ( - -)&
    :
    =



    ( - -)& :
    =



    ( - -)&
    Optimization
    Phase resolution

    View Slide

  86. E F variant
    Property Parsing: Value Calculation
    )& ) ) () II )-)& ) F AC:
    F E )& ) ) .-& )
    )& ) ) F II E F AC:
    F E )& ) ) .-& )
    )& ) ) F AC: F E )& ) )
    Optimization
    Variant resolution
    Package name extraction
    )& ) ) CA CED F E E =


    )& ) ) II
    F AC:
    F E



    )& ) ) II F AC:
    F E



    )& ) ) F AC: F E



    Optimization
    Phase resolution

    View Slide

  87. Property Parsing: Value Calculation
    E F variant
    )& ) ) () II )-)& ) F AC:
    F E )& ) ) .-& )
    )& ) ) F II E F AC:
    F E )& ) ) .-& )
    )& ) ) F AC: F E )& ) )
    Optimization
    Variant resolution
    Package name extraction
    )& ) ) CA CED F E E =


    )& ) ) II
    F AC:
    F E



    )& ) ) II F AC:
    F E



    )& ) ) F AC: F E



    Optimization
    Phase resolution

    View Slide

  88. Property Parsing: Value Calculation
    E F variant
    )& ) ) () II )-)& ) F AC:
    F E )& ) ) .-& )
    )& ) ) F II E F AC:
    F E )& ) ) .-& )
    )& ) ) F AC: F E )& ) )
    Optimization
    Variant resolution
    Package name extraction
    )& ) ) CA CED F E E =


    )& ) ) II
    F AC:
    F E



    )& ) ) II F AC:
    F E



    )& ) ) F AC: F E



    Optimization
    Phase resolution

    View Slide

  89. Property Parsing: Value Calculation
    E F variant
    )& ) ) () II )-)& ) F AC:
    F E )& ) ) .-& )
    )& ) ) F II E F AC:
    F E )& ) ) .-& )
    )& ) ) F AC: F E )& ) )
    Optimization
    Variant resolution
    Package name extraction
    )& ) ) CA CED F E E =


    )& ) ) II
    F AC:
    F E



    )& ) ) II F AC:
    F E



    )& ) ) F AC: F E



    Optimization
    Phase resolution

    View Slide

  90. Property Parsing: Value Calculation
    E F variant
    )& ) ) () II )-)& ) F AC:
    F E )& ) ) .-& )
    )& ) ) F II E F AC:
    F E )& ) ) .-& )
    )& ) ) F AC: F E )& ) )
    Optimization
    Variant resolution
    Package name extraction
    )& ) ) CA CED F E E =


    )& ) ) II
    F AC:
    F E



    )& ) ) II F AC:
    F E



    )& ) ) F AC: F E



    Optimization
    Phase resolution

    View Slide

  91. Results
    > Gradle plugin instead of script
    > Simplified dependencies
    > Correct feature flag values in submodules

    View Slide

  92. Results
    > Gradle plugin instead of script
    > Simplified dependencies
    > Correct feature flag values in submodules

    View Slide

  93. Results
    > Gradle plugin instead of script
    > Simplified dependencies
    > Correct feature flag values in submodules

    View Slide

  94. Results
    > Gradle plugin instead of script
    > Simplified dependencies
    > Correct feature flag values in submodules

    View Slide

  95. Available Now
    > https://github.com/line/feature-flag-android

    View Slide

  96. Summary
    > Solved pain points of feature branches with feature flags
    > Gradle plugin for Android is now available

    View Slide

  97. Thank You

    View Slide