Please enable JavaScript.
Coggle requires JavaScript to display documents.
Aspect-Oriented Programming (AOP) - Coggle Diagram
Aspect-Oriented Programming (AOP)
Definition
A programming paradigm that aims to modularize cross-cutting concerns
Key concepts
Aspect: a modularization of a concern that cuts across multiple classes
Join point: a point in the execution of the program where an aspect can be applied
Advice: the action taken by an aspect at a join point
Pointcut: a predicate that matches join points
Weaving: the process of applying aspects to a target object to create an advised object
Spring AOP: a lightweight AOP framework for use in the Spring framework
AspectJ: a Java-based AOP framework
Types of advice
Before: executed before the join point
After: executed after the join point, regardless of whether the join point succeeded or failed
After returning: executed after the join point, but only if the join point succeeded
After throwing: executed after the join point, but only if the join point threw an exception
Around: executed before and after the join point, allowing the advice to control the execution of the join point
Advantages
Improves modularity by separating cross-cutting concerns from the business logic
Reduces code duplication by encapsulating common functionality in aspects
Improves maintainability by reducing the complexity of the codebase
Disadvantages
Can increase the complexity of the codebase
Can introduce performance overhead due to the added abstraction
May require additional tools and frameworks to implement