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

后端 未结 4 1405
忘了有多久
忘了有多久 2021-01-05 16:03

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

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 16:27

    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.

提交回复
热议问题