0

In my reasearch of Dependendcy Injection so far I haven't seen an example object being treated as both a client and a service (meaning a service [value, factory, etc] which has its own dependencies).

Can a component be both a client and a service without breaking some fundamental aspect of DI? Is this normal to do in DI?

For clarification, I'm asking if a component can both be a dependency, and have dependencies, making it both a client and a service in Dependency Injection.

5

Yes. Think of the classic DI example - a Logger - which itself might take dependencies on a FileSystemWriter and a DatabaseWriter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.