Aspect-Oriented Programming (AOP)
What is Aspect-Oriented Programming (AOP)?
Aspect-Oriented Programming (AOP): Some behaviour (logging, auth checks, metrics) needs to run around many unrelated functions. AOP lets you define that behaviour once, then "weave" it into chosen join points instead of duplicating calls everywhere. Aspect-oriented programming, or AOP, is a way of handling behaviour that many unrelated parts of a program need, such as logging, permission checks or performance measurement. You write that behaviour once and attach it to the places where it should run.
Frequently asked questions about Aspect-Oriented Programming (AOP)
How is Aspect-Oriented Programming (AOP) used in practice?
Without AOP, the same few lines end up copied into hundreds of methods, and someone always forgets one. With AOP, a rule like "time every repository method" lives in one file.
What should you keep in mind with Aspect-Oriented Programming (AOP)?
Java's Spring framework is the best-known user. In other ecosystems the same idea appears in smaller forms: HTTP middleware, decorators in Python and TypeScript, and event listeners in Laravel. Those are usually the better choice, because they are easier to see when reading the code. Use full AOP only where the cross-cutting behaviour is truly everywhere.
At a glance
| Category | Programming paradigms |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |