Annotating the Methods seems like an anti-AOP pattern to me. Of the comments become code and get filled with AOP stuff, it's not an different Form putting the calls into the methods themself, beside some performance improvements when running the code without annotations. But the code will be littered with stuff that should be outside of it.
It makes into a slightly different but still invaluable pattern. I'd rather have code that says what it does, but says it in the most concise way possible, than code that just has black magic running on it in the background.
Re:Introduction to Aspect-Oriented Programming
by pbh101 on Saturday July 12, 2014 @11:14PM
(#8026519)
It's a little different:
1) Reduce 'soft' duplication. Overhead of having many small logging calls everywhere is probably higher than we all want to admit 2) Reduce small variances. Common logging format is useful (as a baseline-- additional logging is probably also useful)
I'm not terribly familiar with AOP but the cognitive overhead IMO is reduced if you just have to act as a client to logging (via annotation) than bespoke implementations at each call site.
Re:Introduction to Aspect-Oriented Programming
by seanmcdirmid on Saturday July 12, 2014 @10:20PM
(#8026425)
This is good advice. You do lose the transparency of the approach in this case, but you are otherwise stuck in a higher-order form of callback hell if you don't.
Though one wonders if they could get rid of even this if they just had some dynamic scoping.
First, the method being given the aspect should be annotated. @LogsArgs or @Transactional. None of this 'oh we just use an auto proxy to apply this to every method' bullshit. Tell me you're doing something.
Second, the annotation should be and to tell you exactly what it's doing with just the name. @LogRequestAndResponse. What does it do? Exactly what it says. If you can't describe the end result easily, then how will the next guy have a clue what just happened?
Whenever I've followed these, I don't regret aspects very often. When I stop following them, people get confused.