I went to the London.pm tech meet last night. There was an excellent selection of talks, but the one that really caught my eye was Tom Hukins talk on Aspect.pm. Now, I’ve looked at AOP before, mostly in the context of Java and AspectJ.
But every time I read about AOP, I came away with my head spinning. The idea should be simple: provide a way to interleave your own code into other methods that you don’t necessarily control. But the frameworks in existence just don’t seem to be that simple.
So, Tom’s talk, Tracing code with Aspect.pm was really useful. It clearly and simply ushowed how to use Aspect.pm to intercept function calls in a nice, practical manner. You can use it to insert tracing into code that you might not control. What’s very nice is that you can also modify parameters on the way in and out. Tom demonstrated how to redirect all HTTP calls to localhost for testing.
Funnily enough, I first came across this behaviour some years ago inside Emacs: Advising Emacs Lisp Functions. It’s quite simple to use…