in Technology by
What is Aspect oriented programming(AOP)?

1 Answer

0 votes
by

One of the key components of Spring Framework is the Aspect oriented programming (AOP) framework. Aspect-Oriented Programming entails breaking down program logic into distinct parts called so-called concerns. The functions that span multiple points of an application are called cross-cutting concerns and these cross-cutting concerns are conceptually separate from the application's business logic. There are various common good examples of aspects like logging, auditing, declarative transactions, security, caching, etc.

The key unit of modularity in OOP is the class, whereas in AOP the unit of modularity is the aspect. Dependency Injection helps you decouple your application objects from each other and AOP helps you decouple cross-cutting concerns from the objects that they affect. AOP is like triggers in programming languages such as Perl, .NET, Java, and others.

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

AOP Terminologies

Before we start working with AOP, let us become familiar with the AOP concepts and terminology. These terms are not specific to Spring, rather they are related to AOP.

Sr.No Terms & Description
1

Aspect

This is a module which has a set of APIs providing cross-cutting requirements. For example, a logging module would be called AOP aspect for logging. An application can have any number of aspects depending on the requirement.

2

Join point

This represents a point in your application where you can plug-in the AOP aspect. You can also say, it is the actual place in the application where an action will be taken using Spring AOP framework.

3

Advice

This is the actual action to be taken either before or after the method execution. This is an actual piece of code that is invoked during the program execution by Spring AOP framework.

4

Pointcut

This is a set of one or more join points where an advice should be executed. You can specify pointcuts using expressions or patterns as we will see in our AOP examples.

5

Introduction

An introduction allows you to add new methods or attributes to the existing classes.

6

Target object

The object being advised by one or more aspects. This object will always be a proxied object, also referred to as the advised object.

7

Weaving

Weaving is the process of linking aspects with other application types or objects to create an advised object. This can be done at compile time, load time, or at runtime.

Related questions

0 votes
    I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    I have an aspect advice like following @AfterReturning("execution(* de.ojk.platform.servicelayer.session. ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    Functional programming language cannot be an object oriented language too 1. True 2. False...
asked Mar 7, 2023 in Technology by JackTerrance
0 votes
    What is Object-Oriented Programming?...
asked Feb 8, 2023 in Technology by JackTerrance
0 votes
    Is Swift an object-oriented programming language?...
asked Nov 30, 2020 in Technology by JackTerrance
0 votes
    By default Spring framework creates all the beans as singletons. Isn't this contradicting with basic Object ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    What is structure analysis briefly explain how the inheritance feature of object oriented programming helps in code reuse? Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    Python is a Procedure Oriented Programming Language true or false Select the correct answer from above options...
asked Dec 6, 2021 in Education by JackTerrance
0 votes
    Python is a Procedure Oriented Programming Language true or false Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    in procedure oriented programming,the global data is loosely attached to the __ Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    Python is a Procedure Oriented Programming Language true or false Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    What is the difference between an object-oriented programming language and object-based programming language?...
asked Nov 17, 2020 in Education by Editorial Staff
+1 vote
    What AOP stands for in Spring? A - Aspect Oriented Programming B - Any Object Programming C - Asset Oriented Programming D - Asset Oriented Protocol...
asked Oct 14, 2020 in Technology by JackTerrance
0 votes
    I am new to Spring AOP. Using annotation based Spring configuration: @Configuration @EnableAspectJAutoProxy( ... Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I have quite a large code base using a variety of different ADO technologies (i.e. some EF and in ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
...