DEV Community

loading...

Discussion on: Dependency injection and Reader Monad

Collapse
restuta profile image
Anton Vynogradenko

It would be interesting to see how this approach scales to multiple downstream dependencies.

Collapse
napicella profile image
Nicola Apicella Author

One way would be to replace multiple dependencies with a parameter object: refactoring.com/catalog/introduceP...

The object might be a domain object or a Tuple in case no domain object makes sense: tutorialspoint.com/scala/scala_tup...

Collapse
restuta profile image
Anton Vynogradenko

Yeah, that makes sense! Do yo have an idea how would that work with multiple dependencies that are needed for different objects at different levels in the object graph?

Usually, when, for example, writing tests, it’s required to “set up” multiple objects like that.

Thread Thread
napicella profile image
Nicola Apicella Author

Hi! I might have some, could you write up a short example to clarify?