AOP面向切面编程
The key unit of modularity in OOP is the class, whereas in AOP the unit of modularity is the aspect. Aspects enable the modularization of concerns (such as transaction management) that cut across multiple types and objects.
Categories:
Aspect-oriented Programming (AOP) complements Object-oriented Programming (OOP) by providing another way of thinking about program structure.
AOP是OOP的延续, 两者互补
为什么要用AOP 为了不涉及过多术语, 在介绍AOP之前, 我们介绍下为什么要提出AOP这个概念
OOP作为Java的核心设计原则, 是存在一些缺点的. 比如日志, 我们知道可以用slf4j 提供的工厂发法返回logger, 但是这个logger的作用范围是初始化的类, 为了实现全局日志需要在所有业务类注入这个logger, 也就是@Slf4j注解 这会导致代码冗余
类似的还有 事务管理