Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Other than logging, and transaction management what are some practical applications of AOP?

Tags:

aop

I understand the principles but i have a hard time seeing where the practical applications are outside of a few. Please enlighten me ;)

like image 477
miguel Avatar asked May 18 '09 21:05

miguel


3 Answers

Ask any support person: logging is not a good application of AOP. They don't care what method is being called inside the app. They care about the significant actions the app is performing and need that information to be presented in a way they understand. To create decent logs, you have to treat logging as another user-interface to the app and design it accordingly.

It would be more accurate to say that AOP can be used to implement tracing.

And I'm not convinced it's useful for transaction management either. I've found plain OO delegation cleanly separates transaction management and business logic.

Still, good question! I've found that arguments for AOP fall into two camps:

  1. Bodging changes into poorly designed code without having to clean up the poor design.
  2. Working around poor development tools, such as weaving tracing into an app because the environment does not have good support for tracing or debugging.
like image 187
Nat Avatar answered Nov 15 '22 08:11

Nat


Both the Spring folks and EJB3 spec committee think that AOP is useful for declarative transactions.

Security, of course.

"AOP In Action" has a nifty example that shows how to use AOP to enforce architectural rules, such as no invocation of the persistence tier outside the service tier.

Qi4j, Rickard Oberg's latest brain child, uses AOP for dynamic class modifications. I've yet to get my head around it completely, but if Rickard is pushing it we'll all want to know someday.

like image 40
duffymo Avatar answered Nov 15 '22 09:11

duffymo


AOP is quite useful when you have a large legacy application and you want to do a across the board change throughout the application.

Recently I used it to partition the http session scope using an additional cookie (other than session id). It quickly relieved a lot of pain from badly written session bound code.

Also checkout Glassbox for a very good example of how AOP can help in making light-weight monitoring and performance management tools

like image 31
Tahir Akhtar Avatar answered Nov 15 '22 09:11

Tahir Akhtar