Reputation: 10482
If I have a facade class containing classes that rely on some dependency, then what is the best way of injecting the dependencies into these classes?
Is it to inject the dependencies into the facade which then in turn injects the dependencies into the classes, or is there something smarter?
Upvotes: 3
Views: 62
Reputation: 233172
A Facade is just a role that an object plays; apart from that, it's no different from any other object, so the same rules apply: when you do Dependency Injection, Constructor Injection is the best choice.
Having a (nested) graph of Facade Services is often a very beneficial design, because it enables each service to take on tasks relevant to its abstraction level.
Upvotes: 2