﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>John Rusk commented on 7 Approaches for AOP in .Net</title><description>Here is one more approach to AOP: http://dotnet.agilekiwi.com/blog/2007/07/claytons-interception.html 
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment8</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment8</guid><pubDate>Sun, 08 Jul 2007 11:33:38 GMT</pubDate></item><item><title>John Rusk commented on 7 Approaches for AOP in .Net</title><description>Here is one more approach to AOP: http://dotnet.agilekiwi.com/blog/2007/07/claytons-interception.html 
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment7</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment7</guid><pubDate>Sun, 08 Jul 2007 11:33:38 GMT</pubDate></item><item><title>A'braham Barakhyahu commented on 7 Approaches for AOP in .Net</title><description>I would like to see this expanded to see what issues each one address.
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment6</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment6</guid><pubDate>Wed, 04 Jul 2007 22:19:13 GMT</pubDate></item><item><title>Stefan Wenig commented on 7 Approaches for AOP in .Net</title><description>I wrote an interception infrastructure using remoting proxies/ContextBoundObject a few years ago, and here's why I think it doesn't fly:
  
- You can't intercept calls on 'this' (actually, I found a way, but it involved native x86 assembler, native thread-static flags that decide whether to intercept or to do the actual call, broke the CLR promise that 'this' would never be a proxy, made it impossible for the debugger to step-into, and all in all was just insanely complex. I dropped it)
  
However, AOP is _very_ incomplete if you can only intercept method calls on object boundaries.
  
- The performance penality was a factor of about 1000 compared to plain virtual calls, although I removed the whole remoting infrastructure and worked with a plain transparent/real proxy pair. It still does involve remoting though. Now a plain call is cheap, and 1000 x cheap might not amount to much if you call a method that actually does stuff. Although that stuff is calling other intercepted methods, that is. So for a general purpose interception infrastructure this is far to heavy. I was very surprised when I recently learned that EntLib is going down this path...
  
  
Using the profiler API is probably the most fragile and unportable here. So this gives us a choice of either subclassing or weaving. I suspect the biggest problem with weaving is binary compatibility. I wonder how this is dealt with when weaving strong-named assemblies.
  
  
The major problems of sublcassing are:
  
  
- Does not work for non-virtual methods, like you said. Given the importance that AOP and interception are gaining, I think something should be done about it. I tried to talk to Eric Lippert about it, but unfortunately he sometimes just doesn't answer...
  
http://blogs.msdn.com/ericlippert/archive/2007/06/14/calling-static-methods-on-type-variables-is-illegal-part-one.aspx (second comment)
  
  
- Can't be used if objects are created with 'new'. Hey, we really need a way to overload 'new' (C#) or 'newobj' (IL)! Or at least some discipline to use factories for object creation. This is an area where code written by Microsoft (or generated by MS-tools) usually looks like it was built by amateurs. Really, this has to stop. 
  
  
You could add that weaving gives you more power to hook right into the body of an existing method, but depending on your point of view, that is not necessarily an advantage. Subclassing constrains you to the interfaces that the author of a class defined, so your aspects should not break if that class changes (or anything derived from that class could break, so at least there is no new category of breaking changes that the author might not be aware of). I think even with AOP you should treat other people's methods as black boxes, unless you use AOP for patching.
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment5</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment5</guid><pubDate>Mon, 02 Jul 2007 08:33:49 GMT</pubDate></item><item><title>Jb Evain commented on 7 Approaches for AOP in .Net</title><description>You can have a look at AspectDNG if you want to have a look at a static weaver that is already implemented.
  
  
http://aspectdng.tigris.org
  
  
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment4</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment4</guid><pubDate>Mon, 02 Jul 2007 07:41:17 GMT</pubDate></item><item><title>Mark Monster commented on 7 Approaches for AOP in .Net</title><description>Hmm, almost a year ago I was looking into AOP. This was just after reading a book about AOP in Java. I found out some people also find Declarative Programming using Attributes a way of Aspect Oriented Programming. I'm not sure about this. Yes we are centralizing our concerns, but we are coupling them tightly with our objects.
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment3</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment3</guid><pubDate>Mon, 02 Jul 2007 07:05:22 GMT</pubDate></item><item><title>Ayende Rahien commented on 7 Approaches for AOP in .Net</title><description>yes
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment2</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment2</guid><pubDate>Mon, 02 Jul 2007 04:49:51 GMT</pubDate></item><item><title>Roy Osherove commented on 7 Approaches for AOP in .Net</title><description>Looking at the code for Rhinomocks, I was pretty sure you were using Dyanmic Proxy to create the mocks (at runtime). You're not?
</description><link>http://ayende.com/2615/7-approaches-for-aop-in-net#comment1</link><guid>http://ayende.com/2615/7-approaches-for-aop-in-net#comment1</guid><pubDate>Mon, 02 Jul 2007 04:17:55 GMT</pubDate></item></channel></rss>