my dog learned polymorphism
The moose likes Spring and the fly likes Usage of AOP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Usage of AOP" Watch "Usage of AOP" New topic

Usage of AOP

tabiul mahmood

Joined: Sep 17, 2009
Posts: 18
Hi All AOP Expert,

This is more of a design question on AOP Usage. The classic usage of AOP has always been in security/logging/transaction etc. I am thinking of using AOP in more business context. I have a method that I need to call across multiple modules in some specific method. Is AOP appropriate here? The business method is not a pure Cross Cutting concern that affects all methods in the application but it does impact significant places. My thinking is that by using AOP can a centralize my code in a single place and prevent tight coupling as maybe I will change the signature of the method and then I will need to change all code that is calling that method. A friend of mine said that AOP should not be used as AOP should only be used non domain or business context.

What do you guys think?


Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Use AOP with caution. AOP gives illusion of simplicity, but actually it's more difficult to understand. Using Annotations is a way to make AOP easier to understand but still not clearest.

If you want to centralize your code, I think you can do without using AOP.

SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I agree and disagree. It always depends on the use case. Is this something that you might want to remove later, or turn on and off at your whim. Then AOP is a great choice for it. Do you mind all the clutter/tangling code of the process in all your other code, that is needed but doesn't represent the Use Case of the method that you tangle this code in? Then AOP is a great choice for it.

But AOP is not the choice for everything. You really need to weight the pros and the cons, and know that sometimes debugging or determining where an error is coming from that might or might not be from AOP can be a little more difficult. Not with a great IDE that you can set break points, but sometimes you have to have two break points. One in the code before the AOP gets called, and one after in the real code. Because Proxies are being used.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Usage of AOP
It's not a secret anymore!