What is Aspect-Oriented Programming?

As mentioned earlier, Aspect-Oriented Programming (AOP) enables modularization of cross-cutting concerns. It complements Object-oriented programming (OOP) which is another programing paradigm. OOP has class and object as key elements but AOP has aspect as key element. Aspects allow you to modularize some functionality across the application at multiple points. This type of functionality is known as cross-cutting concerns. For example, security is one of the cross-cutting concerns in the application, because we have to apply it at multiple methods where we want security. Similarly, transaction and logging are also cross-cutting concerns for the application and many more. Let's see in the following figure how these concerns are applied to the business modules:

As you can see in the preceding figure, there are three main business modules as TransferService, AccountService, and BankService. All business modules require some common functionality such as Security, Transaction management and Logging.

Let's check out what problems we have to face in the application if we do not use the Spring AOP.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset