AOP is an approach to programing that is based on object-oreinted programming. The concerns (distinct parts of functionality) are written separately and then "woven" together using aspect oriented programming.
The key use for AOP is where applications are expected to adapt to new requirements over time by adding new concerns. This is also useful in any system where the modularity of the software is important. Very frequently, AOP is seen in logging frameworks.
Key to the concept of AOP is the concept of a cross cutting concern. This is a concern that spans much of the entire application and changes to such will affect multiple parts of the overall system. Within a pure OOP model, these often increase the coupling and intersystem dependancies. The result of this is that the implementation of the concern is scattered or duplicated across the entire system which results in a loss of modularity.
The ultimate goal of AOP is to encapsulate these cross cutting concerns into a specific aspect that can then be used to retain the modularity of the system.
In the context of logging, one can see that this is a concern that is used throughout the entire system, and implementing logging again and again in each module is the wrong thing to do. Instead, use an aspect to implement the logging so that all the modules of the application can use it - changes to the logging aspect will then be cleanly implemented across the entire system.
Aspect-oriented programming can often be seen in:
- Data validation
- Business logic