Sunday, December 05, 2010

Using AOP to Understand Legacy Code

The article quoted below mentions a technique that I had not seen before that may come in handy someday. The author uses an Aspect-Oriented Programming (AOP) tool, in this case AspectJ, to inject code into a legacy application in order to trace its execution. The article does not show you how to do this (and I'm not going to do that either so perhaps the title of this post is a bit of a teaser) but once you know how to use a particular APO tool injecting tracer code should not be difficult. I just wanted to capture the idea here for future reference (which is the purpose of this links-blog).

Pragmatic Programming Techniques: Understand Legacy Code:
"I have built a tool that allows me to instrument those classes that I am interested so that when I start the system, it will print out all the entry points when they execute. Entry point is the lowest method of the stack trace that you are interested. The tool is based on AspectJ which allows me to inject some print statements when certain methods are executed."

No comments: