0

Trying to decide which path to take for my MVC application and want to follow the AOP approach. Can anyone explain the pros and cons of Unity Custom interception behavior and using Enterprise Library 6.

Experiences and lessons from real world implementation will be very helpful, thank you.

Ant Radha
  • 2,233
  • 1
  • 13
  • 16

2 Answers2

0

I think there is a bit of confusion there between an AOP framework and a Policy Injection pattern. One thing is using a handlers pipeline with Enterprise Library and another is using a Framework like Mono.Cecil or PostSharp to change the behaviors of a program (i.e. to weave a program) at run or compile time.

From the MSDN website:

The implementation of a system that automatically creates a proxy and handler pipeline for methods is similar to the aspect-oriented programming (AOP) approach. However, the Policy Injection Application Block is not an AOP framework implementation for the following reasons:

  • It uses interception to enable only pre-processing handlers and post-processing handlers.
  • It does not insert code into methods.
  • It does not provide interception for class constructors.

Using custom interception/policy injection is good if you want to add support for cross-cutting concern but it has the draw back of keeping a configuration (e.g. registering) your interceptors (which in big code bases could be a problem). You should take into account the performance aspect as well. Custom interception is handled internally by EL using the RealProxy class which uses reflection to call the registered methods.

Using a pure AOP solution would be different as IL code is emitted and injected so it should have better performance too.

Community
  • 1
  • 1
codingadventures
  • 2,924
  • 2
  • 19
  • 36
0

If I get it correct way, you want to implement MVC project in which for IoC (Dependency injection) you want to use UNITY framework which will inject artefact's for your cross cutting concerns like Exception handling or Logging for which you want to use Enterprise library. For code reduction and ease of use AOP is the way you want.

Below is the link that has got a comparison, pros and cons for different .Net frameworks of course Unity one of them.

http://fukyo-it.blogspot.com.ar/2012/10/comparing-net-di-ioc-frameworks.html

Using unity in not a proper way can cause performance issue. Have a look to below link which talks about performance.

http://www.palmmedia.de/blog/2011/8/30/ioc-container-benchmark-performance-comparison

I had used Enterprise library (Pipeline mechanism) for cross cutting concerns, initially used Unity for DI but then switched to StructureMap as it is more lightweight.

VSharma
  • 348
  • 2
  • 12