Todd Fast's Blog

Thursday, Nov 18, 2004

Dependency injection vs. service locator

This article by Martin Fowler describes the dependency injection and service locator patterns and offers some pros and cons of each.

As interesting and useful as dependency injection and inversion of control (IoC) containers are, I tend to agree with Martin's conclusion that the service locator is a somewhat more straightforward pattern, especially if a standard locator mechanism like JNDI is available. On the flip side, as developers become more and more accustomed to dependency injection, particularly as a primary idiom for application development, it does offer some interesting opportunities to (at least seemingly) reduce application complexity.

Comments:

Yeah, service locator is a more straightforward ANTIPATTERN. I never understood how a smart guy Fowler could be defending this singleton nightmare.

Posted by Unknown on November 18, 2004 at 03:22 AM PST #

Post a Comment:
Comments are closed for this entry.

Archives

Tags

Feeds

Search

Links

Navigation

Referers