0

I'm beginning to learn about to how to use DI containers. I'm finding myself using a lot of "service" classes (e.g. ParsingService) with a few dependencies injected.

Is it possible that I'm overusing service classes if that's what I gravitate towards whenever I need a central place to consume several dependencies?

Thank you.

gcso
  • 2,315
  • 3
  • 28
  • 50
  • 2
    This question already covered the same ground: http://stackoverflow.com/questions/5144622/confusion-with-interface-abstraction – Mark Seemann Mar 17 '11 at 08:01

1 Answers1

4

Often, you can use Constructor Injection instead of "Services" to accomplish the same, or similar goals. This also often has many advantages, and is more in line with many IoC container goals.

I'd recommend Martin Fowler's article on the subject, particularly his section Service Locator vs Dependency Injection. He discusses the advantages of both approaches.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373