What is Aspect-Oriented Programming(AOP)? By using the diagram below, the concept can be understood in a few seconds.
The cross-cutting concerns problem
First take a took at the diagram below, and think about what could be the problem.
1. Code tangling: the logging code is mixed with business logic.
2. Code scattering: caused by identical code put in every module.
The logging function is a called "cross-cutting concern". That is, a function that is used in many other modules, such as authentication, logging, performance, error checking, data persistence, storage management, to name just a few.
By using Object-Oriented Programming (OOP), we can define low coupling and high cohesion system. However, when it comes to cross-cutting concerns, it does not handle it well for the reason that it does not relation between handle core concerns and cross-cutting concerns.
Solution from AOP
<pre><code> String foo = "bar"; </code></pre>