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 guest on November 17, 2004 at 07:22 PM PST #

Post a Comment:
Comments are closed for this entry.
About

toddfast

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today