What is the usual approach for hiding the implemen...
# kodein
What is the usual approach for hiding the implementation of some dependency from the dependent classes? When I register some instance I register it via its interface type but create an instance of the implementation.
Copy code
val kodein = Kodein { bind<TimeProvider>() with singleton { TimeProviderImpl() } }
With injecting I again refer to the dependency via its interface type
Copy code
val timeProvider by appKodein.lazyInstance<TimeProvider>()
However, since both
are required to be publicly visible, the IDE will hint both classes as type argument at the injection line. This may lead to coding mistakes (just happened to me) that will lead to runtime errors. Is there some recommended way to structure dependencies (interfaces and their implementations)? The main reason for using injection here is making it testable by later on injecting deterministic testing mocks. Right now the production dependency interface and implementation reside in the same file, whereas the Kodein instance is inside my Android