views:

666

answers:

2
+4  Q: 

IoC, AOP and more

What is an IoC container?

What is an IoC/DI framework?

Why do we need a framework for IoC/DI?

Is there any relationship between IoC/DI and AOP?

What is Spring.net/ninject with respect to IoC and AOP?

+2  A: 

JMSA,

James Kovacs wrote a fantastic article which covers many of your questions I would recommend reading it Here

Spring.Net, Ninject, Unity, Castle Windsor, Autofac are all IOC containers which are configurable in different ways, many of them do also support AOP.

Frameworks for IOC/DI are useful because they provide standard mechanisms, for example if you are hiring a new developer it is much easier to say, we use this framework and pass them the links to the tutorials / help guide. At the same time these frameworks are tried and tested by a large community / companies.

Let me know if any of your questions remain unanswered after reading the article and the above answes and I'll do my best to provide further assistance.

Peter
Thanks Peter! It really helped!
Is there any relationship between IoC/DI and AOP?
To some degree there is a relationship there. If you look into AOP it mostly gets applied for things like Logging, and Security permissions style of cross cutting concerns.In the case of logging a lot of developers would use that along with DI / IOC so that they could switch logging providers (say swap log4net to enterprise library logging).But the true answer is you don't need DI or IoC to implement AOP and to implement DI or IoC you don't need to use AOP.
Peter
The Microsoft Unity container does use both aop and DI to specify dependencies.For example if you had a dll that had services and one that had data access code you could specify that the service dll depends on the data access dll and therefore instruct unity to load the data access dll and initialize it before attempting to initialize the services dll.
Peter
Another flavour of DI / IoC is using a Service locator pattern. you may want to research this also. Martin Fowlers blog has a lot on this topic. toolkit has linked to his blog below.
Peter
+1  A: 

Martin Fowler has a good article here on the meaning of Inversion of Control and Dependency Injection.

Spring.NET usage AOP is described in detail here. I'm more familiar with the Java-based version of Spring, so I cannot say with absolutely certainty that Spring.NET currently only supports proxy-based AOP.

That is, a class to be advised must implement an interface. Spring will create a dynamic proxy that implements this interface and delegates to the original target instance.

Although it does state:

In a future release we will implement proxies using inheritance, which will allow you to proxy classes without interfaces as well and will remove some of the remaining raw reference issues that cannot be solved using composition-based proxies.

toolkit