Aspect Oriented Programming

Blog > Programming

Aspect-Oriented Programming is a software development approach. It helps the programmer to make Cross-Cutting Concerns modular. It prevents long code blocks and repetitive codes make reuse and care of the codes easier.

What are Cross Cutting Concerns?

We can say Cross-Cutting Concerns are isolated functions that can be used for all layers of a project instead of codes for a specific layer. Logging, caching, security, and exception handling are some examples of them.

AOP C# Example

You can see a complex class above. Let's make it tidier by using Aspect.

It is tidier now, but let's see how these aspects work.

Inceptors

Inceptors help us to interfere with the lifecycle of the methods before they run, after they run or when they make a mistake. While some interceptors are placed in the code during the run time some interceptors are placed in the code at the compile time.

References

https://www.javacodegeeks.com/spring-interview-questions-and-answers.html#6

Tags