mercredi 7 septembre 2022

Android Multimodule design - Best way to concentrate info in one file without requiring it to be a dependency

I have a project with dozens of modules for each app feature. Additionally, the project requires feature flags to enable/disable features in the app. In a similar fashion, each module requires some REST services to be called.

In order to accommodate these flags and endpoint constants, there are two main strategies:

  1. place all constants into one file, and add a dependency to that common module, f.e. Features.kt and Endpoints.kt
  2. Place the endpoints and constants only in the module where it is relevant, however, some flags may be relevant in many modules (f.e. add some security measure which is traversal to the module-feature purpose itself).

Using 2 is good for decoupling, but it becomes a maintenance problem because extracting all of the current endpoints, or making sure the feature flags don't repeat id becomes difficult to coordinate or require some external tooling.

Using 1 has the main problem of requiring my modules to recompile each time a new toggle or endpoint constant is added, which makes the compilation time a big issue.

Are there any alternatives that retrieve the best of both worlds? maybe some scripting or gradle processes that ease this.

Aucun commentaire:

Enregistrer un commentaire