除了日志记录和事务管理之外,AOP 还有哪些实际应用? [英] Other than logging, and transaction management what are some practical applications of AOP?

查看:34
本文介绍了除了日志记录和事务管理之外,AOP 还有哪些实际应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解这些原则,但我很难看出实际应用程序在哪些方面超出了少数人的范围.请赐教;)

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

推荐答案

询问任何支持人员:日志记录不是 AOP 的一个好的应用.他们不关心在应用程序内部调用了什么方法.他们关心应用程序正在执行的重要操作,并需要以他们理解的方式呈现这些信息.要创建体面的日志,您必须将日志记录视为应用的另一个用户界面并进行相应的设计.

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.

更准确地说,AOP 可用于实现跟踪.

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

而且我也不相信它对事务管理有用.我发现简单的 OO 委托将事务管理和业务逻辑完全分开.

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.

仍然是个好问题!我发现 AOP 的争论分为两个阵营:

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

  1. 将更改引入设计不佳的代码,而无需清理糟糕的设计.
  2. 解决糟糕的开发工具,例如将跟踪编织到应用中,因为环境对跟踪或调试没有很好的支持.

这篇关于除了日志记录和事务管理之外,AOP 还有哪些实际应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆