I understand the principles but i have a hard time seeing where the practical applications are outside of a few. Please enlighten me ;)
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:
- Bodging changes into poorly designed code without having to clean up the poor design.
- Working around poor development tools, such as weaving tracing into an app because the environment does not have good support for tracing or debugging.
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.
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
I've only just started exploring how I might use AOP. So far I've used it for dependency injection and to implement an interface to support two way data binding in some UI code.
© 2022 - 2024 — McMap. All rights reserved.