Aspect-Oriented Programming is used when you have a "Cross-Cutting Concern," something that affects the whole program, and can't be neatly boxed up into an ordinary class.
The canonical example of AOP is logging. Your entire application needs logging, but you don't want to new up a logger object every time you want to log something in a class, because that tightly ties your classes to a logger object, and scatters logging code throughout your application.
Instead, what you want to do is have a logger class (perhaps a static one, so you don't have to instantiate it), and then have some way to call that class from anywhere. You want to keep it loosely-coupled, so that you can swap out the logger class for a different one, if you want to.
There are a number of ways to call a class via AOP. In C#, one way to do it is by using Attributes:
[MyLogger()]
CallingThisMethodCallsTheLogger(int someParameter)
{
// Do something with someParameter that has nothing to do with the logger
}
Another way to call class methods via AOP is to instrument them. This can be done by performing binary rewrite of the class methods, so that they call the AOP method first, and then call the usual method in the usual way. Instrumenting classes could be done, for example, to measure their performance.
Standard terminology used in Aspect-oriented programming may include:
Cross-cutting concerns: Even though most classes in an OO model
will perform a single, specific function, they often share common,
secondary requirements with other classes.
Advice: This is the additional code that you want to apply to
your existing model. In our example, this is the logging code that
we want to apply whenever the thread enters or exits a method.
Pointcut: This is the term given to the point of execution in
the application at which cross-cutting concern needs to be applied.
In our example, a pointcut is reached when the thread enters a
method, and another pointcut is reached when the thread exits the
method.
Aspect: The combination of the pointcut and the advice is
termed an aspect. In the example above, we add a logging aspect
to our application by defining a pointcut and giving the correct
advice.
http://en.wikipedia.org/wiki/Aspect-oriented_programming