none
Static and dynamic weaving in AOP RRS feed

  • Question

  • Hi,

    I need to implement Aspect oriented programming in C# for implementing cross cutting concerns like logging, security verification etc

    I have three options for this:-

    1. PostSharp

    2. Enterprise Library Policy injection block

    3. Spring.net

    4. Castle Dynamic Proxy

    Can somebody please guide me as which one of above mentioned frameworks implements AOP using static weaving and which one uses Dynamic weaving.

    Also please guide me as for better performance, which type should be used.

    Thanks in advance

    Thompson

    Wednesday, September 15, 2010 6:06 AM

Answers

  • ReSharper is one of those things that fascinates me and I can't make up my mind about it.

    Is it a really clever or is it something that looks clever but just introduces a new way of breaking your code.

    Castle allows you to substitute interfaces.  So eg you can have a wrapper round the non-logged code which does your logging and switch that in and out at run time based on a switch/config. 

    Castle is pretty lightweight and I would far rather use it than EL.  I don't like EL.  Never measured the two side by side but my money would be on Castle. 

    It doesn't change the compiled code though so I'm not sure whether that counts as static or dynamic weaving,  or what.

    I think Spring allows that sort of approach as well but I've only ever read about it rather than used it.  It's a port of Java technology and AFAIK not many .net teams use it.  So you might have a resource issue there.

    • Marked as answer by thompson3 Saturday, October 9, 2010 5:43 AM
    Wednesday, September 15, 2010 9:00 AM
  • Well, If I would choose one of these, I would choose PostSharp, I am not sure about its license, it's something that you need to see, but it it changes your compiled code. It's better choice regarding performance.

     

    I've already used EL for AOP, it sucks, private methods aren't reched and the classes you want to be caught by any aspect has to be "resolved", i didn't like it.

     

    You might want to see this article.

    http://stackoverflow.com/questions/2090299/postsharp-has-no-effect-on-speed

    • Marked as answer by thompson3 Saturday, October 9, 2010 5:43 AM
    Friday, October 8, 2010 4:50 PM

All replies

  • ReSharper is one of those things that fascinates me and I can't make up my mind about it.

    Is it a really clever or is it something that looks clever but just introduces a new way of breaking your code.

    Castle allows you to substitute interfaces.  So eg you can have a wrapper round the non-logged code which does your logging and switch that in and out at run time based on a switch/config. 

    Castle is pretty lightweight and I would far rather use it than EL.  I don't like EL.  Never measured the two side by side but my money would be on Castle. 

    It doesn't change the compiled code though so I'm not sure whether that counts as static or dynamic weaving,  or what.

    I think Spring allows that sort of approach as well but I've only ever read about it rather than used it.  It's a port of Java technology and AFAIK not many .net teams use it.  So you might have a resource issue there.

    • Marked as answer by thompson3 Saturday, October 9, 2010 5:43 AM
    Wednesday, September 15, 2010 9:00 AM
  • Well, If I would choose one of these, I would choose PostSharp, I am not sure about its license, it's something that you need to see, but it it changes your compiled code. It's better choice regarding performance.

     

    I've already used EL for AOP, it sucks, private methods aren't reched and the classes you want to be caught by any aspect has to be "resolved", i didn't like it.

     

    You might want to see this article.

    http://stackoverflow.com/questions/2090299/postsharp-has-no-effect-on-speed

    • Marked as answer by thompson3 Saturday, October 9, 2010 5:43 AM
    Friday, October 8, 2010 4:50 PM
  • Hi Black,

    Thanks a lot for sharing your experience. I appreaciate your comments.

    Can you please share some code to signify how EL makes things bad, like your talked about classes needs to be "resolved" and how this is resolved in postsharp.

    Do you have any experience about castle.

    Thanks again

    Cheers

    Saturday, October 9, 2010 5:43 AM