Aspect Oriented Programming (AOP) is an imperative/procedural programming paradigm like OOP or Functional. It differs from other procedural paradigms in that its main concern is the functionality needed across different layers of an application architecture.
For example, logging is a service that is required by all layers of an application and the code behind this service is pretty much the same despite the client using it. So whether it’s the database that’s logging some information, the presentation layer, the business logic, the code will probably be very similar. Despite the differences in the layers of an application, there exist these cross-cutting concerns. Other concerns, besides logging, may include things like security, error handling, etc.
AOP and other paradigms are not mutually exclusive; you can have software that uses both AOP and OOP, for example. Where OOP modularizes the functionality of the application and divides it into tiers, AOP modularizes the cross-cutting concerns and divides it into services. So there might be a service for security which can be invoked by any layer of the application. Think of an n-tiered application with its different layers; AOP would take this and do a projection on the security issues, or a projection on the logging issues, and isolate those… modularize those.
In a regular system, security might be scattered across the entire application. If you need to change some security logic, you’ll have to do it everywhere. With an AOP enlightened system, however, security would be a module/service. If you need to make a change, just change the service and that’s it. Plus you don’t want code that deals with security to be embedded in your business logic; it just gets in the way. AOP allows you to deal with it separately.
Some Terms
- cross-cutting concerns: concepts like security and logging that are common to otherwise unrelated parts of a system
- advice: the code to be applied for the cross-cutting concerns; e.g. the code used for logging
- join-point or pointcut: a place in the code where the advice needs to be applied; e.g. logging needs to happen after this call to the DB
- aspect: the advice and the places it will be applied (the pointcuts) are together called the aspect
See: http://en.wikipedia.org/wiki/Aspect_oriented_programming.