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

查看:313
本文介绍了除了日志记录和事务管理之外,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天全站免登陆