AOP - a bad example?
Richard emailed in anonymously with this comment:
A few months ago I decided I was fed up with hearing all the hype about AOP and thought I'd better actually look into it to actually understand it. Now, what really annoyed me about trying to get started in understanding AOP is that the most prevalent example on using AOP concerns logging. In my opinion (and experience) logging is NOT a good area for using AOP. In fact, I have never seen an decent example of how to use AOP. Not to say that one doesn't exist. I'm lead to believe that Spring using AOP behind the scenes for transaction handling, etc.
I don't log entry and exit into methods. If I have a function that I'm not sure is behaving properly I will add debug statements at various points during the method. When I'm logging, it's some value that probably isn't supplied as an input parameter to the method. I'm also concerned that writing AOP-based logging statements has the knock-on effect of doubling the size of your code base.
Having said all that, I have found a suitable application for AOP-based logging in my application. I use it for logging exceptions at the DAO layer with all the information I need. AOP has been very useful in that I have been able (through Spring AOP) to write a short class that can log a method call signature and the generated stack trace. Unfortunately I don't think I can apply it elsewhere right now.
I suppose what I'm trying to say is that it would have helped me to have seen a really useful application of AOP methods to solving a problem because, to me, logging ain't it.