views:

313

answers:

3

Is the provider pattern an implementation of IOC? If not, why not?

(reading through martin fowlers article on ioc)

A: 

Spring uses BeanFactory and its concrete implementations, most important of which is ApplicationContext. Don't know what Guice does.

duffymo
A: 

See the related question #484815

toolkit
+1  A: 

In my opinion, yes the Provider pattern is a form of Inversion of Control.

What's my reasoning?

At it's core IoC is a very generic concept, so much so that Martin Fowler talks about reading user input from the command line as being a form of IoC.

With the Provider model the inversion happens when the provider framework decides which provider will be used when a given method is called. For example when you invoke Membership.GetUser your code is delegating control of which Membership provider to use, to the provider framework.

As Fowler says "Inversion of Control is a common characteristic of frameworks" and if you think about it many patterns are concerned with IoC (e.g Strategy pattern). I would go as far as to say that even polymophism is a form of IoC (a point I would happily like to hear a counter argument to).

Schneider