1.

What is Aspect Orientated Programming?

Answer»

Aspect Orientated Programming (AOP) is a mechanism for adding certain behavior by virtually breaking the program logic into distinct parts called concerns. This helps in increasing modularity by cross-cutting the concerns. These cross-cutting concerns SPAN across multiple points of an application and are conceptually separate from the application's BUSINESS logic. For e.g. transaction management, authentication, logging, security, etc.

It is a concept in contrast to OBJECT Oriented Programming (OOPS) and Dependency Injection (DI).

The key unit of modularity in OOPS is the class, whereas in AOP the unit of modularity is the aspect. DI allows the application to decouple the objects from each other and AOP helps to decouple cross-cutting concerns from the objects that they affect.

Spring AOP module provides interceptors to intercept an application. For example, when a method is executed, we can add custom functionality before or after the method is executed.

Below are few important AOP concepts:

  • Aspect: It is a concern that we are TRYING to implement like logging, transaction management.
  • Advice: It is the specific ACTION that needs to be done i.e. the code to be executed.
  • Pointcut: It is the expression which determines the methods on which Advice should be applied.


Discussion

No Comment Found