Hello Guys. I am building a multi module app and h...
# android-architecture
b
Hello Guys. I am building a multi module app and had an intersting idea of decoupling gradle modules to gain build performance. I wanted to hear your opinion of this idea: • app • lib1-api • lib1-impl • lib2-api • lib2-impl “lib1- impl” needs the SOME functionality of “lib2-api”. (e.g formatting text) Option A: normally the gradle module of “lib1-impl” looks like this
Copy code
dependencies {
   implementation("lib2-api")
}
this means every time i change something in “lib2-api” “lib1-impl” needs to be recompiled Option B (maybe faster one): “lib1-impl” has not dependency to “lib2-api”. instead we use dagger in the “app” module and glue it together like this:
Copy code
@Module
object Lib1ImplModule {
  @Provides
  fun provideLib1Impl(lib2Api: Lib2Api): Lib1Impl {
    return new Lib1Impl(
      formatText = { text -> 
        lib2Api.formatText(text)
      }
    )
  }
}
So the implementation of Lib1 has a constructor parameter for a function which returns this formatted text. And the dagger implementation forwards this text to lib2Api and returns the formatted text. What do you think which approach will be better? Defining dependencies and losing build performance or decoupling as much as possible module dependencies and gain build performance. General question: Are there any drawbacks using functions as constructor parameters?
j
lib1-impl depends on lib1-api?